#1 2017-03-24 23:07:14

mohsenti
Member
Registered: 2015-04-11
Posts: 72

Custom Reader for JSON Serialization with array value

Hi,

AS suggested in forum I'm trying to make a new custom reader for my JSON like document https://synopse.info/files/html/Synopse … ml#TITL_52 and it goes well.
But I dont know who to handle array values and I cant find any sample.
One of the properties is array and trying many function including JSONArrayDecode cant decode the JSON array.
What function I should use for arrays?

Last edited by mohsenti (2017-03-24 23:07:55)

Offline

#2 2017-03-25 09:12:58

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,655
Website

Re: Custom Reader for JSON Serialization with array value

You may simply use TDynArray.LoadFromJSON, with a local TDynArray.
See how JSONToObject() uses it.

Offline

#3 2017-03-25 12:27:10

mohsenti
Member
Registered: 2015-04-11
Posts: 72

Re: Custom Reader for JSON Serialization with array value

So I done something like this:

  DA.Init(TypeInfo(TItem),V.FChilds);
  DA.LoadFromJSON(Values[2]);

The only question is how can I set the value with the property "Childs" not the exact value like "FChilds"?

Offline

#4 2017-03-31 22:27:42

Del
Member
Registered: 2017-03-24
Posts: 20

Re: Custom Reader for JSON Serialization with array value

@mohsenti do you have some sample code using a custom reader for json serialization to share? I will be need that in a while and initial analysis of custom reader did not seem clear to me quickly so an exmple might pave way for me, many thanks:)

Offline

#5 2017-04-01 22:12:35

mohsenti
Member
Registered: 2015-04-11
Posts: 72

Re: Custom Reader for JSON Serialization with array value

Hi,

I did that just like this part: https://synopse.info/files/html/Synopse … #TITLE_244
If you got problem, I will try to help you.

Offline

#6 2017-04-02 10:25:36

Del
Member
Registered: 2017-03-24
Posts: 20

Re: Custom Reader for JSON Serialization with array value

Thanks. I want to apply a custom reader to a json string returning an object list, any samples for this scenario?

Offline

#7 2017-04-02 13:21:03

mohsenti
Member
Registered: 2015-04-11
Posts: 72

Re: Custom Reader for JSON Serialization with array value

There was sample in doc but I could not make it work and I used array for that and only for auto reader not custom readers.

Offline

Board footer

Powered by FluxBB