关于JSON
public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.Append("{");
sb.Append("totalCount:" + totlalCount.ToString() + ",");
sb.Append("success:" + _success.ToString().ToLower() + ",");
sb.Append("error:\"" + _error.Replace("\"", "\\\"") + "\",");
sb.Append("singleInfo:\"" + singleInfo.Replace("\"", "\\\"") + "\",");
sb.Append("data:[");
int index = 0;
sb.Append("{");
if (arrData.Count <= 0)
{
sb.Append("}]");
}
else
{
foreach (string val in arrData)
{
index++;
if (val != "<BR>")
{
sb.Append(val + ",");
}
else
{
sb = sb.Replace(",", "", sb.Length - 1, 1);
sb.Append("},");
if (index < arrData.Count)
{
sb.Append("{");
}
}
}
sb = sb.Replace(",", "", sb.Length - 1, 1);
sb.Append("]");
}
sb.Append("}");
return sb.ToString();
}
刚接触JSON,不知道这段代码最后给出的是个什么样的架构,请朋友们帮帮忙,还有学JSON怎么能快点上手,因为项目要用到、、、先谢谢各位了
------解决方案--------------------你输出字符串看看喽!~。看百度百科就行了。
------解决方案--------------------
count=0
{totalCount:xxx,success:xxx,error:"xxx(如果有\" 就变成\\")",singleInfo:"xxx同前一",
data:[{}]}
count!=0
{totalCount:xxx,success:xxx,error:"xxx(如果有\" 就变成\\")",singleInfo:"xxx同前一",
data:[{val
}]}
后面的看不懂到底是什么意思。 看的头疼。
------解决方案--------------------你了解一下JSON格式就清楚了