Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You'll have to do it recursively. Something like this:</p> <pre><code>const INDENT_SIZE = 2; procedure PrettyPrintJSON(value: TJSONValue; output: TStrings; indent: integer = 0); forward; procedure PrettyPrintPair(value: TJSONPair; output: TStrings; last: boolean; indent: integer); const TEMPLATE = '%s : %s'; var line: string; newList: TStringList; begin newList := TStringList.Create; try PrettyPrintJSON(value.JsonValue, newList, indent); line := format(TEMPLATE, [value.JsonString.ToString, Trim(newList.Text)]); finally newList.Free; end; line := StringOfChar(' ', indent * INDENT_SIZE) + line; if not last then line := line + ',' output.add(line); end; procedure PrettyPrintJSON(value: TJSONValue; output: TStrings; indent: integer); var i: integer; begin if value is TJSONObject then begin output.add(StringOfChar(' ', indent * INDENT_SIZE) + '{'); for i := 0 to TJSONObject(value).size - 1 do PrettyPrintPair(TJSONObject(value).Get(i), output, i = TJSONObject(value).size - 1, indent + 1); output.add(StringOfChar(' ', indent * INDENT_SIZE) + '}'); end else if value is TJSONArray then //left as an exercise to the reader else output.add(StringOfChar(' ', indent * INDENT_SIZE) + value.ToString); end; </code></pre> <p>This covers the basic principle. WARNING: I wrote this up off the top of my head. It may not be correct or even compile, but it's the general idea. Also, you'll have to come up with your own implementation of printing a JSON array. But this should get you started.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload