void DeserializeObject(JsonTokenizer tokenizer, object instance, JsonTypeCacheEntry cache) { bool isNameExpected = false; while (true) { if (isNameExpected) { tokenizer.ReadString(); } else { tokenizer.ReadNext(); if (tokenizer.SpecialChar == '}') { return; } if (!tokenizer.TokenIsString) { throw new JsonException("String expected"); } isNameExpected = true; } string n = tokenizer.Token; tokenizer.ReadColon(); JsonTypeMemberEntry me; if (cache.Members != null && cache.Members.TryGetValue(n, out me) && me.WriteValue != null) { tokenizer.ReadNext(); object v; if (TryDeserializeValue(tokenizer, me.MemberType, out v)) { me.WriteValue(instance, v); } } else { tokenizer.SkipValue(); } tokenizer.ReadNext(); switch (tokenizer.SpecialChar) { case ',': break; case '}': return; default: throw new JsonException("Unexpected token"); } } }
void DeserializeCollection(JsonTokenizer tokenizer, Type elementType, Action <object> add) { while (true) { object v; if (TryDeserializeValue(tokenizer, elementType, out v)) { add(v); } tokenizer.ReadNext(); switch (tokenizer.SpecialChar) { case ',': tokenizer.ReadNext(); break; case ']': return; default: throw new JsonException("Unexpected token"); } } }