source: binary-improvements/7dtd-server-fixes/src/JSON/JSONObject.cs@ 174

Last change on this file since 174 was 154, checked in by alloc, 10 years ago

fixes

File size: 682 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace AllocsFixes.JSON
6{
7 public class JSONObject : JSONNode
8 {
9 private Dictionary<string, JSONNode> nodes = new Dictionary<string, JSONNode> ();
10
11 public void Add (string name, JSONNode node)
12 {
13 nodes.Add (name, node);
14 }
15
16 public override string ToString ()
17 {
18 StringBuilder sb = new StringBuilder ("{");
19 foreach (KeyValuePair<string, JSONNode> kvp in nodes) {
20 sb.Append (String.Format ("\"{0}\":", kvp.Key));
21 sb.Append (kvp.Value.ToString ());
22 sb.Append (",");
23 }
24 if (sb.Length > 1)
25 sb.Remove (sb.Length - 1, 1);
26 sb.Append ("}");
27 return sb.ToString ();
28 }
29
30 }
31}
32
Note: See TracBrowser for help on using the repository browser.