Example #1
0
        public string ArrayStart(int indent)
        {
            StringBuilder sb = new StringBuilder();

            SJSON.WriteNewLine(sb, indent);
            sb.Append("[");
            return(sb.ToString());
        }
Example #2
0
        public string ObjectEnd(int indent)
        {
            StringBuilder sb = new StringBuilder();

            SJSON.WriteNewLine(sb, indent);
            sb.Append("}");
            return(sb.ToString());
        }
Example #3
0
        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));
        }
Example #5
0
        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());
        }
Example #6
0
 // 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);
     }
 }
Example #7
0
        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());
        }
Example #8
0
 // 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));
     }
 }
Example #9
0
 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)));
 }