protected static object parseValue(char[] json, ref int index, ref bool success) { switch (MUJson.lookAhead(json, index)) { case 1: return(MUJson.parseObject(json, ref index)); case 3: return(MUJson.parseArray(json, ref index)); case 7: return(MUJson.parseString(json, ref index)); case 8: return(MUJson.parseNumber(json, ref index)); case 9: MUJson.nextToken(json, ref index); return(bool.Parse("TRUE")); case 10: MUJson.nextToken(json, ref index); return(bool.Parse("FALSE")); case 11: MUJson.nextToken(json, ref index); return(null); } success = false; return(null); }
protected static Hashtable parseObject(char[] json, ref int index) { Hashtable table = new Hashtable(); MUJson.nextToken(json, ref index); bool done = false; while (!done) { int token = MUJson.lookAhead(json, index); if (token != 0) { if (token == 6) { MUJson.nextToken(json, ref index); } else { if (token == 2) { MUJson.nextToken(json, ref index); return(table); } string name = MUJson.parseString(json, ref index); if (name == null) { return(null); } token = MUJson.nextToken(json, ref index); if (token != 5) { return(null); } bool success = true; object value = MUJson.parseValue(json, ref index, ref success); if (!success) { return(null); } table[name] = value; } continue; } return(null); } return(table); }
protected static ArrayList parseArray(char[] json, ref int index) { ArrayList array = new ArrayList(); MUJson.nextToken(json, ref index); bool done = false; while (!done) { int token = MUJson.lookAhead(json, index); if (token != 0) { if (token == 6) { MUJson.nextToken(json, ref index); } else { if (token == 4) { MUJson.nextToken(json, ref index); break; } bool success = true; object value = MUJson.parseValue(json, ref index, ref success); if (!success) { return(null); } array.Add(value); } continue; } return(null); } return(array); }