[fpc-pascal] JSON register new data types for custom output/input
Graeme Geldenhuys
mailinglists at geldenhuys.co.uk
Tue May 17 13:16:05 CEST 2016
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.
eg:
Current I write a TColor value to JSON and it results in:
"BackgroundColor": -2147483648
Yes, technically that is correct, and Delphi/FPC code will understand
that, but other programming languages will not. So I was wondering if we
could somehow tell fpjson to render TColor output for example as:
"BackgroundColor": #FF00AA
or maybe
"BackgroundColor": $FF00AA
or maybe
"BackgroundColor": { "R": $FF, "G": $00, "B": $AA }
or maybe
"BackgroundColor": { "R": 255, "G": 0, "B": 170 }
The first two are probably preferred over the latter two for my needs.
This is not just for TColor, but I have various other data types I think
would be useful having improved JSON output/input in a slightly
different format. eg: Improving the formatting of floating point values
would also be nice.
eg: Currently I get:
"Width": 2.66680002212524
but would prefer
"Width": 2.6668
Regards,
Graeme
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/
My public PGP key: http://tinyurl.com/graeme-pgp
More information about the fpc-pascal
mailing list