public string ArrayStart(int indent) { StringBuilder sb = new StringBuilder(); SJSON.WriteNewLine(sb, indent); sb.Append("["); return(sb.ToString()); }
public string ObjectEnd(int indent) { StringBuilder sb = new StringBuilder(); SJSON.WriteNewLine(sb, indent); sb.Append("}"); return(sb.ToString()); }
public string ObjectStart(string key, int indent) { StringBuilder sb = new StringBuilder(); SJSON.WriteNewLine(sb, indent); sb.Append(key); sb.Append(" = {"); return(sb.ToString()); }
static void TestMerge(string s_parent, string s_left, string s_right) { Hashtable parent = Sjson(s_parent); Hashtable left = Sjson(s_left); Hashtable right = Sjson(s_right); Hashtable res = JsonDiff.Merge(parent, left, right); System.Diagnostics.Debug.WriteLine(SJSON.Encode(res)); }
public string ObjectField(Hashtable a, string key, int indent) { if (!a.ContainsKey(key)) { return(""); } StringBuilder sb = new StringBuilder(); SJSON.WriteObjectField(a, key, sb, indent); return(sb.ToString()); }
// Saves a JSON or SJSON file. static void Save(Hashtable h, string s) { if (_use_json) { JSON.Save(h, s); } else { SJSON.Save(h, s); } }
public string ArrayItem(object o, int indent) { if (o == null) { return(""); } StringBuilder sb = new StringBuilder(); SJSON.WriteNewLine(sb, indent); SJSON.Write(o, sb, indent); return(sb.ToString()); }
// Loads a JSON or SJSON file. static Hashtable Load(string s) { if (!File.Exists(s)) { Error(String.Format("File not found: {0}", s)); } if (_use_json) { return(JSON.Load(s)); } else { return(SJSON.Load(s)); } }
public override void Write(StringBuilder sb, string key) { sb.AppendFormat("{0} = {1}\n", key, SJSON.EncodeObject(_value)); }
static Hashtable Sjson(string s) { return(SJSON.Decode(Encoding.UTF8.GetBytes(s))); }