public override void Add(String key, JsonNode item) { if(!String.IsNullOrEmpty(key)) { if(dict.ContainsKey(key)) { dict[key] = item; } else { dict.Add(key, item); } } else { dict.Add(Guid.NewGuid().ToString(), item); } }
public JsonLazyCreator(JsonNode node, String key) { this.node = node; this.key = key; }
private void Set(JsonNode val) { if(key == null) { node.Add(val); } else { node.Add(key, val); } node = null; }
public override void Add(string key, JsonNode item) { var tmp = new JsonClass(); tmp.Add(key, item); Set(tmp); }
public JsonLazyCreator(JsonNode node) { this.node = node; key = null; }
public override void Add(JsonNode item) { var tmp = new JsonArray(); tmp.Add(item); Set(tmp); }
public override JsonNode Remove(JsonNode node) { list.Remove(node); return node; }
public override void Add(String key, JsonNode item) { list.Add(item); }
public override JsonNode Remove(JsonNode node) { try { var item = dict.Where(k => k.Value == node).First(); dict.Remove(item.Key); return node; } catch { return null; } }
public virtual JsonNode Remove(JsonNode node) { return node; }
public virtual void Add(JsonNode item) { Add("", item); }
public virtual void Add(String key, JsonNode item) { }
static void AddElement(JsonNode ctx, string token, string token_name, bool token_is_string) { if(token_is_string) { if(ctx is JsonArray) { ctx.Add(token); } else { ctx.Add(token_name, token); // assume dictionary/object } } else { var number = Numberize(token); if(ctx is JsonArray) { ctx.Add(number); } else { ctx.Add(token_name, number); } } }