Beispiel #1
0
 internal static string ToJsonString(object obj, bool compressed, int level)
 {
     if (obj == null)
     {
         return("null");
     }
     else if (obj is BjSJsonObject)
     {
         return((obj as BjSJsonObject).ToJsonString(compressed, level));
     }
     else if (obj is BjSJsonArray)
     {
         return((obj as BjSJsonArray).ToJsonString(compressed, level));
     }
     else if (obj is string)
     {
         return("\"" + BjSJsonHelper.EscapeString((string)obj) + "\"");
     }
     else if (obj is decimal)
     {
         return(((decimal)obj).ToString(System.Globalization.CultureInfo.InvariantCulture));
     }
     else if (obj is bool)
     {
         return((bool)obj ? "true" : "false");
     }
     else
     {
         return("");
     }
 }
Beispiel #2
0
 internal string ToJsonString(bool compressed, int level)
 {
     if (compressed)
     {
         return(String.Format("\"{0}\":{1}", BjSJsonHelper.EscapeString(this.Name), BjSJsonHelper.ToJsonString(this.Value, true, 0)));
     }
     else
     {
         return(String.Format("\"{0}\" : {1}", BjSJsonHelper.EscapeString(this.Name), BjSJsonHelper.ToJsonString(this.Value, false, level + 1)));
     }
 }
Beispiel #3
0
 internal string ToJsonString(bool compressed, int level)
 {
     if (compressed)
     {
         return(String.Format("{{{0}}}", String.Join(",", Members.Select(m => m.ToJsonString(true, 0)).ToArray())));
     }
     else if (this.Members.Count == 0)
     {
         return("{ }");
     }
     else
     {
         string levelStr = BjSJsonHelper.GetLevelString(level);
         string level1   = BjSJsonHelper.GetLevelString(level + 1);
         return(String.Format("{{\r\n{0}{2}\r\n{1}}}", level1, levelStr, String.Join(String.Format(",\r\n{0}", level1),
                                                                                     Members.Select(m => m.ToJsonString(false, level + 1)).ToArray())));
     }
 }
Beispiel #4
0
 internal string ToJsonString(bool compressed, int level)
 {
     if (compressed)
     {
         return(String.Format("[{0}]", String.Join(",", this.Values.Select(v => BjSJsonHelper.ToJsonString(v, true, 0)).ToArray())));
     }
     else if (this.Values.Count == 0)
     {
         return("[ ]");
     }
     else
     {
         string levelStr = BjSJsonHelper.GetLevelString(level);
         string level1   = BjSJsonHelper.GetLevelString(level + 1);
         return(String.Format("[\r\n{0}{2}\r\n{1}]", level1, levelStr, String.Join(String.Format(",\r\n{0}", level1),
                                                                                   this.Values.Select(v => BjSJsonHelper.ToJsonString(v, false, level + 1)).ToArray())));
     }
 }
Beispiel #5
0
 public override string ToString()
 {
     return(String.Format("{0} : {1}", this.Name, BjSJsonHelper.GetValueDisplayString(this.Value)));
 }
Beispiel #6
0
 /// <summary>
 /// Returns the data type of the entry's value at the given index
 /// </summary>
 public BjSJsonValueKind GetValueKind(int index)
 {
     return(BjSJsonHelper.GetValueKind(this.Values[index]));
 }
Beispiel #7
0
 /// <summary>
 /// Returns the data type of the member's value at the given index
 /// </summary>
 public BjSJsonValueKind GetValueKind(int index)
 {
     return(BjSJsonHelper.GetValueKind(this.Members[index].Value));
 }