ProxyObject DecodeObject() { var proxy = new ProxyObject(); // Ditch opening brace. json.Read(); // { while (true) { // ReSharper disable once SwitchStatementMissingSomeCases switch (NextToken) { case Token.None: return(null); case Token.Comma: continue; case Token.CloseBrace: return(proxy); default: // Key string key = DecodeString(); if (key == null) { return(null); } // : if (NextToken != Token.Colon) { return(null); } json.Read(); // Value proxy.Add(key, DecodeValue()); break; } } }
void EncodeProxyObject(ProxyObject value) { if (value.Count == 0) { builder.Append("{}"); } else { AppendOpenBrace(); var firstItem = true; foreach (var e in value.Keys) { AppendComma(firstItem); EncodeString(e); AppendColon(); EncodeValue(value[e], false); firstItem = false; } AppendCloseBrace(); } }