superobject 数组增加
在使用superobject过程中,经常遇到在有的json中增加数组数据,2次格式弄错了,经常把数组数据,写成字符数据。写demo,备注一下。
procedure TForm1.btn1Click(Sender: TObject); var jo,arry,bb: ISuperObject; strSQL,sResult,stmp: string; sZTBH: string; arry1: TSuperArray; begin stmp := ' {"gqcpbh":[{"cpbh":"0101"},{"cpbh":"0602"}],"resmsg":"数据查询成功","resid":"0"}'; jo := SO(stmp); bb := SO('{eee:seee,ooo:st}'); jo['a']:=SA([]); jo.A['a'].Add(bb); jo.A['a'].Add(so('{11:33}')); ShowMessage( jo.AsJSon(true,true)); end;
显示结果:
{
"a": [
{
"eee": "seee",
"ooo": "st"
},
{
"11": 33
}
],
"gqcpbh": [
{
"cpbh": "0101"
},
{
"cpbh": "0602"
}
],
"resid": "0",
"resmsg": "数据查询成功"
}