通过 SuperObject 生成 json string

(*
{
"name": "Henri Gourvest", /* this is a comment */
"vip": true,
"telephones": ["000000000", "111111111111"],
"age": 33,
"size": 1.83,
"adresses": [
{
"adress": "blabla",
"city": "Metz",
"pc": 57000
},
{
"adress": "blabla",
"city": "Nantes",
"pc": 44000
}
]
}
*) procedure SaveJson;
var
json, json_sub: ISuperObject;
begin
json := SO; json.S['name'] := 'Henri Gourvest';
json.B['vip'] := TRUE;
json.O['telephones'] := SA([]);
json.A['telephones'].S[] := '';
json.A['telephones'].S[] := '';
json.I['age'] := ;
json.D['size'] := 1.83; json.O['addresses'] := SA([]); json_sub := SO;
json_sub.S['address'] := 'blabla';
json_sub.S['city'] := 'Metz';
json_sub.I['pc'] := ;
json.A['addresses'].Add(json_sub); json_sub.S['address'] := 'blabla';
json_sub.S['city'] := 'Nantes';
json_sub.I['pc'] := ;
json.A['addresses'].Add(json_sub); json.SaveTo('C:\json_out.txt'); json := nil;
json_sub := nil;
end;
上一篇:Less tips:声明变量之前可以引用变量!


下一篇:ZOJ 2676 Network Wars(网络流+分数规划)