5,927
社区成员




var JSon_Root :TlkJSONobject; var Rlt_Str Rlt_Str :String;
Rlt_Str :='{"error_response":{"code":"22","zh_desc":"授权者不是商家","en_desc":"the franchisor not businessmen"}}'
JSon :=TlkJSON.ParseText(Rlt_Str) as TlkJSONobject;
if JSon.Field['error_response'] <>nil then begin
JSon_Root :=JSon.Field['error_response'] as TlkJSONobject;
with JSon_Root do begin
ShowMessage(getString('code'), ); //22
ShowMessage(getString('en_desc')); //the franchisor not businessmen
ShowMessage(Field['zh_desc'].Value); //为什么是空值,而不是授权者不是商家
end;
end;
var
Rlt_Str: string;
JSon, JSon_Root: TlkJSONobject;
valStr: string;
begin
Rlt_Str :=
'{"error_response":{"code":"22","zh_desc":"授权者不是商家","en_desc":"the franchisor not businessmen"}}';
Rlt_Str := UTF8Encode(Rlt_Str);
JSon := TlkJSONobject.Create;
JSon := TlkJSON.ParseText(Rlt_Str) as TlkJSONobject;
if JSon.Field['error_response'] <> nil then
begin
JSon_Root := JSon.Field['error_response'] as TlkJSONobject;
with JSon_Root do
begin
valStr := valStr + getString('code') + #10;
valStr := valStr + getString('en_desc') + #10;
valStr := valStr + (Field['zh_desc'] as TlkJSONstring).Value;
end;
end;
ShowMessage(valStr);
end;
