[fpc-pascal] JSON register new data types for custom output/input

Michael Van Canneyt michael at freepascal.org
Tue May 17 13:23:51 CEST 2016



On Tue, 17 May 2016, Graeme Geldenhuys wrote:

> Hi,
>
> Is it possible (or on some wish list) to register new data types with
> fpjson so it can understand and generate custom output, and understand
> reading back that custom output.

There cannot be custom output in JSON, then it would no longer be JSON. 
JSON is a fixed defined format; it does not allow "deviation".

What you probably need is what RTTIJSON does, or the restbase class.
Alternatively WST also has a serializer that outputs JSON.

But they all have 1 thing in common: they take an object instance,
and serialize this to JSON or vice versa. Custom types must be coerced into
one of the types that JSON understands.

Michael.



More information about the fpc-pascal mailing list