[fpc-devel] JSON Beautifier

Michael Van Canneyt michael at freepascal.org
Fri Sep 24 14:43:42 CEST 2010

On Fri, 24 Sep 2010, theo wrote:

>> Have you tried the JSONVIewer app  in Lazarus ? tools/jsonviewer ?
>> It displays (and allows to manipulate) the JSON in a completely graphical
>> manner.
> Now I had the time. Looks great! Thanks for this.
> (I had to copy the json files from FPC trunk, it didn't compile with my 2.4 because of "Extract")
>> I'm already working on a formatted JSON call, but I'm not yet there.
> This would be great for debugging using ShowMessage or writeln.
> Any idea when this feature will be ready?

Somewhere next week.

> I have another question.
> What exactly is the purpose of TJSONNull in fpjson?

To represent a null value ?

> In Javascript, i can do sth. like:
> var myJSONObject =
> {
>  "Name": "test",
>  "testDate": null
> };
> alert(myJSONObject.testDate);
> myJSONObject.testDate=Date();
> alert(myJSONObject.testDate);
> Which I understand as: "There is no date assigned initially, but this can be changed".
> I can't figure out how to do this with fpjson. except probably deleting and adding the value/type.

You can create the above object with:

myJSONObject:=TJSONObject.Create(['name', 'test', 'testdate', Nil]);

and then



myjson.isnull['testdate'] = true

will evaluate to true.

After that you can do


Note that JSON does not know the date type.


More information about the fpc-devel mailing list