Recent

Author Topic: Convert array of (generic) records to JSON  (Read 2675 times)

tudi_x

  • Hero Member
  • *****
  • Posts: 532
Convert array of (generic) records to JSON
« on: July 23, 2018, 02:10:35 pm »
hi,
please advise how could an array of records with unknown structure be converted (marshaled) to JSON. for example:

type
  TExRecord = record
    property1: string;
    property2: string;
  end;

  TArrayRecords = array of TExRecord;   

i have seen https://www.freepascal.org/docs-html/fcl/fpjson/index.html but is there something more generic?
for example something that could work unchanged if i add a third property to the record (like reflection maybe).

type
  TExRecord = record
    property1: string;
    property2: string;
    property3: string;
  end;

thank you
Lazarus 2.0.2 64b on Debian LXDE 10

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Convert array of (generic) records to JSON
« Reply #1 on: July 23, 2018, 07:07:18 pm »
Did you see this?

tudi_x

  • Hero Member
  • *****
  • Posts: 532
Re: Convert array of (generic) records to JSON
« Reply #2 on: July 24, 2018, 09:23:19 am »
did not see it.
RecordToJSON looks exactly what i was looking for.
hope it is integrated the soonest in the standard library and an example added.
thank you
Lazarus 2.0.2 64b on Debian LXDE 10

 

TinyPortal © 2005-2018