// ClassicalSharp copyright 2014-2016 UnknownShadow200 | Licensed under MIT
//-----------------------------------------------------------------------
//
// Copyright (c) 2011, The Outercurve Foundation.
//
// Licensed under the MIT License (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.opensource.org/licenses/mit-license.php
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Nathan Totten (ntotten.com), Jim Zimmerman (jimzimmerman.com) and Prabir Shrestha (prabir.me)
// https://github.com/facebook-csharp-sdk/simple-json
//-----------------------------------------------------------------------
// original json parsing code from http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html
// This is a significantly cutdown version of the original simple-json repository.
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
namespace Launcher {
public static class Json {
const int TOKEN_NONE = 0, TOKEN_CURLY_OPEN = 1, TOKEN_CURLY_CLOSE = 2;
const int TOKEN_SQUARED_OPEN = 3, TOKEN_SQUARED_CLOSE = 4, TOKEN_COLON = 5;
const int TOKEN_COMMA = 6, TOKEN_STRING = 7, TOKEN_NUMBER = 8;
const int TOKEN_TRUE = 9, TOKEN_FALSE = 10, TOKEN_NULL = 11;
static Dictionary ParseObject( string json, ref int index, ref bool success ) {
Dictionary table = new Dictionary();
NextToken( json, ref index ); // skip {
while( true ) {
int token = LookAhead( json, index );
if( token == TOKEN_NONE ) {
success = false; return null;
} else if( token == TOKEN_COMMA ) {
NextToken( json, ref index );
} else if( token == TOKEN_CURLY_CLOSE ) {
NextToken( json, ref index );
return table;
} else {
string name = ParseString( json, ref index, ref success );
if( !success ) {
success = false; return null;
}
token = NextToken( json, ref index );
if( token != TOKEN_COLON ) {
success = false; return null;
}
object value = ParseValue( json, ref index, ref success );
if( !success ) {
success = false; return null;
}
table[name] = value;
}
}
}
static List