private JSONNode ReadObject() { JSONNode jSONNode = new JSONNode(); SkipWhitespace(); if (reader.Peek() != 123) { Debug.LogError((object)"malformed json: no starting '{'"); return(null); } reader.Read(); while (reader.Peek() != 125) { if (reader.Peek() == 44) { reader.Read(); } if (reader.Peek() == 125) { break; } SkipWhitespace(); string fieldName = ReadFieldName().Trim(); SkipWhitespace(); reader.Read(); IJSONFieldValue val = ReadValue(); jSONNode.AddField(fieldName, val); SkipWhitespace(); } reader.Read(); return(jSONNode); }
//--------------------------------------------------------------------------------- // ReadObject //--------------------------------------------------------------------------------- private JSONNode ReadObject() { JSONNode node = new JSONNode(); SkipWhitespace(); // read '{' if (reader.Peek() != '{') { Debug.LogError("malformed json: no starting '{'"); return(null); } reader.Read(); while (reader.Peek() != '}') { if (reader.Peek() == ',') { reader.Read(); } if (reader.Peek() == '}') { break; } SkipWhitespace(); // read field name string fieldName = ReadFieldName().Trim(); // read ':' SkipWhitespace(); reader.Read(); //Console.WriteLine("after : found " + ((char) reader.Peek())); // read value IJSONFieldValue val = ReadValue(); //Console.WriteLine("adding field " + fieldName + " " + val); node.AddField(fieldName, val); SkipWhitespace(); } reader.Read(); // remove trailing "}" return(node); }
//--------------------------------------------------------------------------------- // ReadObject //--------------------------------------------------------------------------------- private JSONNode ReadObject() { JSONNode node = new JSONNode(); SkipWhitespace(); // read '{' if(reader.Peek() != '{') { Debug.LogError("malformed json: no starting '{'"); return null; } reader.Read(); while(reader.Peek() != '}') { if(reader.Peek() == ',') reader.Read(); if(reader.Peek() == '}') break; SkipWhitespace(); // read field name string fieldName = ReadFieldName().Trim(); // read ':' SkipWhitespace(); reader.Read(); //Console.WriteLine("after : found " + ((char) reader.Peek())); // read value IJSONFieldValue val = ReadValue(); //Console.WriteLine("adding field " + fieldName + " " + val); node.AddField(fieldName, val); SkipWhitespace(); } reader.Read(); // remove trailing "}" return node; }
//--------------------------------------------------------------------------------- // Content //--------------------------------------------------------------------------------- public JSONOutStream Content(string tag, string value) { node.AddField(tag, new JSONStringFieldValue(value)); return(this); }