Beispiel #1
0
 /// <summary>
 /// 添加一个属性
 /// </summary>
 /// <returns></returns>
 public JsonObject AppendChild(string name, string value) {
     JsonObject jObj = new JsonObject(name);
     jObj.Value = value;
     base.Children.Add(jObj);
     gbObject = true;
     return jObj;
 }
Beispiel #2
0
 private JsonObject NewChild() {
     if (!dp.IsArray) {
         if (szName == "") throw new Exception("名称不能为空!");
     }
     if (szValue != "") throw new Exception("语法错误!");
     JsonObject dNew = new JsonObject(GetNormalName(szName));
     //dp = dp[GetNormalName(szName)];
     dp.Children.Add(dNew);
     szName = "";
     szValue = "";
     return dNew;
 }
Beispiel #3
0
 /// <summary>
 /// 保存对象
 /// </summary>
 private void SaveObject() {
     if (szName == "") throw new Exception("缺少名称!");
     if (szValue == "") throw new Exception("缺少值!");
     dyk.Data.LayerData.DataObject dNew = new JsonObject(GetNormalName(szName));
     dNew.Value = GetNormalValue(szValue);
     dp.Children.Add(dNew);
     szName = "";
     szValue = "";
 }
Beispiel #4
0
 public JsonParser(JsonObject obj) {
     gObj = obj;
     nLine = 0;
     nIndex = 0;
 }
Beispiel #5
0
 //数据初始化
 private void Init() {
     gHeader = new JttpHeader(base["Header"]);
     gData = base["Data"];
 }
Beispiel #6
0
 public JttpHeader(JsonObject obj) {
     gObj = obj;
 }
Beispiel #7
0
 /// <summary>
 /// 克隆一个对象
 /// </summary>
 /// <returns></returns>
 public JsonObject Clone() {
     JsonObject xup = new JsonObject(base.Name);
     xup.Value = base.Value;
     xup.IsArray = base.IsArray;
     for (int i = 0; i < this.Children.Count; i++) {
         JsonObject xupNew = this[i].Clone();
         xup.Children.Add(xupNew);
     }
     return xup;
 }
Beispiel #8
0
 /// <summary>
 /// 将一个Json对象合并到当前对象
 /// </summary>
 /// <param name="obj"></param>
 public void Coalition(JsonObject obj) {
     if (obj.Count > 0) {
         for (int i = 0; i < obj.Count; i++) {
             string szName = obj[i].Name;
             this[szName].Coalition(obj[i]);
         }
     } else {
         this.Value = obj.Value;
     }
 }