[Lazarus] Convert record to JSON?

Michael Van Canneyt michael at freepascal.org
Sat Jul 21 18:05:30 CEST 2018



On Sat, 21 Jul 2018, Sven Barth via Lazarus wrote:

> === code begin ===
>
> s := streamer.RecordToJSONString(@t1, TypeInfo(t1));
> // becomes
> s := streamer.specialize RecordToJSONString<TMyRecord>(t1);
>
> destreamer.JSONToRecord(s, @t2, TypeInfo(t2));
> // becomes
> destreamer.specialize JSONToRecord<TMyRecord>(s, t2);
>
> === code end ===
>
> @Michael: maybe we can integrate this in fpjsonrtti directly?


:-) :-) :-)

I am glad you proposed it, saves me the trouble of asking it. 
I was planning to extend JSONRTTI so it can handle more cases 
(I want to replace the rest JSON handling with it), 
so this can definitely be included.

I'll study your code and get back to you. 
Thanks for the sample code !! :)

Michael.


More information about the Lazarus mailing list