Rev | Line | |
---|
[154] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.Text;
|
---|
| 4 |
|
---|
| 5 | namespace 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.