using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Sog; namespace Operation { public class HttpResultStringBuilder { // public List columns = new List(); // public Dictionary data = new Dictionary(); public int ret; public string m_result; public Dictionary m_keyvalue = new Dictionary(); public void AddKeyValue(string key,string value) { TraceLog.Trace("HttpResultStringBuilder.AddKeyValue key {0} value {1}", key, value); if(m_keyvalue.ContainsKey(key)) { m_keyvalue[key] = value; } else { m_keyvalue.Add(key, value); } } public void AddTable(string tablename,Dictionary table) { foreach (var item in table) { m_keyvalue.Add(item.Key, item.Value); } } public string ToJsonString() { //return "{ \"ret\":\"0\",\"token\":\"123456\"}"; string allline = ""; allline += "\"ret\":" + ret.ToString(); foreach (var pair in m_keyvalue) { allline += ","; string key = "\"" + pair.Key + "\""; string value ="\"" + pair.Value + "\""; allline += key + ":" + value; } return "{ " + allline + "}"; } } }