I am unable to deserialize a json data.

Hi!

I have to deserialize json data and store it into list of records. But I am getting some error. I am attaching the screenshot here.

Hi Gaurav,

Please check the attached demo example how to serialize and deserialize json.

Hope this helps

Hi Guarav,

How does your json and the structure you try to deserialize look like? 

Gaurav Pandey wrote:

Hi!

I have to deserialize json data and store it into list of records. But I am getting some error. I am attaching the screenshot here.


Can you upload the oml?

Hi Gaurav,

From your error message what I can understand is that your json string and the type in which you want to deserialize are different. 

Your json string contains items in an array but you are trying to deserialize it to an type which is not a list or any similar type. Please check in your code if this is the case.

If you can't share OML just share the json you are trying to deserialize and the screen shot of your json deserialize node properties.

Outsystems cannot handle every json, for example dynamice structures/types.

It really needs to be of a kind of key-value structure.

Hello Gaurav,

Can you provide the input JSON that is throwing the error?  That would be very helpful to determine the problem.

Hi All!

I am attaching the screenshot of the structure that was created when I pasted the Json data. Also I am sharing the data action screenshot for better understanding of the issue. I will have to check if I can share the OML or not.

I have used Ardo Json forge component here. 


Hi Guarav,

Please make a PoC application that demonstrates this issue alone instead of using your complete application. Also make sure to anonymise the JSON (that we really need to have to be able to help you).

Did you by the way use OutSystems function to convert a JSON to a Structure to create the listed structures (see screenshot)? And why are you using ArdoJSON instead of the native Json capabilities?


The error you show in your latest post btw is already telling you what the problem is (but not where the problem is). In your structures you have one property set to a list while in the json this is a single object. Find this mismatch and you are a step closer to solving your issue;

Vincent Koning wrote:

Hi Guarav,

Please make a PoC application that demonstrates this issue alone instead of using your complete application. Also make sure to anonymise the JSON (that we really need to have to be able to help you).

Did you by the way use OutSystems function to convert a JSON to a Structure to create the listed structures (see screenshot)? And why are you using ArdoJSON instead of the native Json capabilities?


The error you show in your latest post btw is already telling you what the problem is (but not where the problem is). In your structures you have one property set to a list while in the json this is a single object. Find this mismatch and you are a step closer to solving your issue;

Yes I have used Outsystems function to create the structures. I will try to share OML.


I have attached the OML here .


Thanks!!

Carlos Lessa wrote:

Gaurav Pandey wrote:

Hi!

I have to deserialize json data and store it into list of records. But I am getting some error. I am attaching the screenshot here.


Can you upload the oml?

I have uploaded the OML.


Nikhil Gaur wrote:

Hi Gaurav,

From your error message what I can understand is that your json string and the type in which you want to deserialize are different. 

Your json string contains items in an array but you are trying to deserialize it to an type which is not a list or any similar type. Please check in your code if this is the case.

If you can't share OML just share the json you are trying to deserialize and the screen shot of your json deserialize node properties.

I have attached the Json Data.

Thanks


J. wrote:

Outsystems cannot handle every json, for example dynamice structures/types.

It really needs to be of a kind of key-value structure.

I have attached the Json .


Craig St.Jean wrote:

Hello Gaurav,

Can you provide the input JSON that is throwing the error?  That would be very helpful to determine the problem.

I have attached the input JSON.


Solution

Hi Guarav,

Your issue lies here;


HREF is in one case a single object and in another case a list. This can't be solved in code. This fault is also in place in the source XML and the only way to fix this issue is by fixing you XML input data;


Again, this is not something OutSystems can fix for you. Fix the data and your problem is solved.

Succes,

Vincent

Solution

Vincent Koning wrote:

Hi Guarav,

Your issue lies here;


HREF is in one case a single object and in another case a list. This can't be solved in code. This fault is also in place in the source XML and the only way to fix this issue is by fixing you XML input data;


Again, this is not something OutSystems can fix for you. Fix the data and your problem is solved.

Succes,

Vincent


Thanks Vincent, for pointing out the flaw. I am able to display the data but I am unable to iterate the list in order as you could see that the structure generated is a complicated one. It seems that the list has records which are themselves list types. Morever I am unable to think of a solution to map the data for eg: which para text should go with which heading. Any help would be appreciated.

Thanks,

Gaurav