Beispiel #1
0
 public string ToJSON()
 {
     StringBuilder builder = new StringBuilder();
     JSON json = new JSON();
     Hashtable ht = new Hashtable();
     ht["text"] = this.Text;
     ht["value"] = this.Value;
     builder.Append(json.Json(ht, false));
     if (null != this.Data)
     {
         builder.Append(",");
         Hashtable htData = BlueSky.Utilities.ReflectionUtil.GetObjectFieldValueHash(this.Data);
         builder.Append(json.JsonKeyValue("data", json.Json(htData, true), true));
     }
     builder.Append(",");
     builder.Append(json.JsonKeyValue("childrens", this.ToChildrenJSON(), true));
     return json.JsonEnd(builder.ToString());
 }
Beispiel #2
0
 private string ToChildrenJSON()
 {
     StringBuilder builder = new StringBuilder();
     JSON json = new JSON();
     foreach (TreeNode node in this.Nodes)
     {
         StringBuilder builderNode = new StringBuilder();
         Hashtable ht = new Hashtable();
         ht["text"] = node.Text;
         ht["value"] = node.Value;
         builderNode.Append(json.Json(ht, false));
         if (null != node.Data)
         {
             builderNode.Append(",");
             Hashtable htData = BlueSky.Utilities.ReflectionUtil.GetObjectFieldValueHash(node.Data);
             builderNode.Append(json.JsonKeyValue("data", json.Json(htData, true), true));
         }
         builderNode.Append(",");
         builderNode.Append(json.JsonKeyValue("childrens", node.ToChildrenJSON(), true));
         if (builder.Length >= 1)
         {
             builder.Append(",");
         }
         builder.Append(json.JsonEnd(builderNode.ToString()));
     }
     return json.Json2Array(builder.ToString());
 }