How to parse a JSON string in Delphi?

后端 未结 5 955
太阳男子
太阳男子 2020-12-14 18:00

How can I parse the JSON string

{\"data\":{\"results\":[{\"Branch\":\"ACCT590003\"}]}}

using the T

5条回答
  •  别那么骄傲
    2020-12-14 18:34

    Using SuperObject Library https://github.com/hgourvest/superobject/

    var json: iSuperObject;
        data: string;
    
    begin
      json := SO('{"data":{"results":[{"Branch":"ACCT590003"}]}}'); // shorthand
    // or equal:  JSON := TSuperObject.ParseString('{"data":{"results":[{"Branch":"ACCT590003"}]}}');
    
      data := json.S['data.results[0].Branch'];
    
      WriteLn('Result is: ', data);
    end.
    

提交回复
热议问题