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:
program test; {$mode objfpc}{$H+} uses classes, fpjson; var r, j: TJSONObject; a: TJSONArray; s: TStringlist; BEGIN s := TStringlist.create; r := TJSONObject.create; a := TJSONarray.create; j := TJsonObject.create; j.strings['name'] := 'Luciano de Souza'; j.integers['age'] := 38; j.strings['city'] := 'NiterĂ³i'; j.strings['country'] := 'Brazil'; a.add(j.clone); j.clear; j.strings['name'] := 'Mariella Molinari'; j.integers['age'] := 29; j.strings['city'] := 'Padova'; j.strings['country'] := 'Italy'; a.add(j.clone); r.add('people', a); s.text := r.AsJson; s.SavetoFile('test.txt'); try finally j.free; r.free; s.free; end; END. 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? -- Luciano de Souza _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal