[fpc-pascal] Formating JSON outputs

Michael Van Canneyt michael at freepascal.org
Tue Jan 28 13:18:20 CET 2014



On Tue, 28 Jan 2014, luciano de souza wrote:

> Hello all,
>
> JSON is a very easy format to handle with Freepascal. However, the
> output is not so readable when the number of registers increase. An
> example of it is:
>
[snip]

> The corresponding output is:
>
> { "people" : [{ "name" : "Luciano de Souza", "age" : 38, "city" :
> "NiterĂ³i", "country" : "Brazil" }, { "name" : "Mariella Molinari",
> "age" : 29, "city" : "Padova", "country" : "Italy" }] }
>
> My question is: is there a way to automatically format it? Breaking
> lines? Becoming easy the reading?

Yes. Use the FormatJSON function.
Note that it is slower than the AsJSON function, because of the formatting.

Michael.


More information about the fpc-pascal mailing list