Arrays Delphi2010 Json解析
如何在delphi 2010上解析这一行:Arrays Delphi2010 Json解析,arrays,json,delphi,parsing,delphi-2010,Arrays,Json,Delphi,Parsing,Delphi 2010,如何在delphi 2010上解析这一行: {"list": [{"id": "107","name": "John","fname": "Doe"}, {"id": "108","name": "Alex","fname": "Man"}], "success": 1, "count": "2"} 要解析JSON,请使用JSON解析器。我尝试重新制作各种解析示例,但失败了=(你用的是哪个JSON解析器?你知道JSON解析器是什么吗?如果你的答案是否定的,那
{"list": [{"id": "107","name": "John","fname": "Doe"},
{"id": "108","name": "Alex","fname": "Man"}],
"success": 1,
"count": "2"}
要解析JSON,请使用JSON解析器。我尝试重新制作各种解析示例,但失败了=(你用的是哪个JSON解析器?你知道JSON解析器是什么吗?如果你的答案是否定的,那就好了。然后我们可以告诉你,让你的生活更轻松。现在翻拍一个例子,它是有效的,但他似乎没有纠正。如果出现异常,然后你吞下它,并且
js
没有初始化。所有后续使用js
因此无效
procedure parse_3;
var
txt: PAnsiChar;
js: TJSONArray;
lat: string;
i: integer;
begin
try
txt :=
'{"list": [{"id": "107","name": "John","fname": "Doe"},{"id": "108","name": "Alex","fname": "Man"}],"success": 1, "count": "2"}';
js := ParseJSON(txt);
except
end;
if Assigned(js) and (js is TJSONObject) then
begin
if js.field['success'].value = 1 then
begin
for i := 0 to StrToInt(js.field['count'].value) - 1 do
begin
showmessage(js.field['list'].child[i].field['id'].value +' | '+js.field['list'].child[i].field['name'].value +' | '+js.field['list'].child[i].field['fname'].value);
end;
end;
end;
end;