How do I pretty-print JSON in Delphi?

前端 未结 5 782
盖世英雄少女心
盖世英雄少女心 2020-12-31 19:22

I am looking for a function that will take a string of JSON as input and format it with line breaks and indentations (tabs).

Example: I have input line:



        
5条回答
  •  感情败类
    2020-12-31 19:50

    If you're working with Delphi XE or newer, you can use the delphi-xe-json library

    function PrettyPrint (aJSON : string) : string;
    var
      jo : IJSONObject
    begin
      jo := TJSON.NewObject(aJSON);
      result := jo.ToString(true);
    end;
    

提交回复
热议问题