You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

60 lines
1.6 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Sog;
namespace Operation
{
public class HttpResultStringBuilder
{
// public List<string> columns = new List<string>();
// public Dictionary<string, string> data = new Dictionary<string, string>();
public int ret;
public string m_result;
public Dictionary<string, string> m_keyvalue = new Dictionary<string, string>();
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<string,string> 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 + "}";
}
}
}