internal virtual string imm_get_json_path_struct(YJSONObject jsonObject, string[] paths, int ofs) { string key = paths[ofs]; if (!jsonObject.has(key)) { return(""); } YJSONContent obj = jsonObject.get(key); if (obj != null) { if (paths.Length == ofs + 1) { return(obj.toJSON()); } if (obj is YJSONArray) { return(imm_get_json_path_array(jsonObject.getYJSONArray(key), paths, ofs + 1)); } else if (obj is YJSONObject) { return(imm_get_json_path_struct(jsonObject.getYJSONObject(key), paths, ofs + 1)); } } return(""); }
protected internal virtual List <string> imm_json_get_array(byte[] json) { YJSONArray array = new YJSONArray(YAPI.DefaultEncoding.GetString(json)); array.parse(); List <string> list = new List <string>(); int len = array.Length; for (int i = 0; i < len; i++) { YJSONContent o = array.get(i); list.Add(o.toJSON()); } return(list); }
public override string toJSON() { StringBuilder res = new StringBuilder(); res.Append('{'); string sep = ""; foreach (string key in parsed.Keys.ToArray()) { YJSONContent subContent = parsed[key]; string subres = subContent.toJSON(); res.Append(sep); res.Append('"'); res.Append(key); res.Append("\":"); res.Append(subres); sep = ","; } res.Append('}'); return(res.ToString()); }