[Lazarus] Convert record to JSON?

Bo Berglund bo.berglund at gmail.com
Fri Jul 20 18:22:02 CEST 2018


I have an application that manages the configuration of an embedded
device, which communicates over TCP/IP. Currently I have implmented a
protocol with a command identifier for each data item and the way to
send the data is by sending a packet with the command ID plus the data
to the open socket.

This is less than optimal but was done when the config item number was
low, but it seems to increase over time so I want to find a better
way.

I have just looked into fpJSON a bit (read the wiki but no coding
yet).

I have this question:
The config data are stored in a record and consists of a mix of data
types like strings and numbers as well as booleans.
Is there a simple way to encode the record as a JSON message to be
sent to the device with all of the information in one packet?
If so how would one go about coding that transformation?

If possible I would like it to be transparent such that if the record
is extended later it would automatically include the new members?


-- 
Bo Berglund
Developer in Sweden



More information about the Lazarus mailing list