Error with json to record list ardo-json

Error with json to record list ardo-json

  
Here is the error message: 

Object reference not set to an instance of an object.
Stack:
   at OutSystems.NssardoJSON.CssardoJSON.FieldField.type()
   at OutSystems.NssardoJSON.CssardoJSON.readSimpleValue(JToken json, Type fieldType)
   at OutSystems.NssardoJSON.CssardoJSON.MssJSON2RecordList(String ssJSON, Object ssRecordList)
   at ssWEB.RssExtensionardoJSON.MssJSON2RecordList(HeContext heContext, String inParamJSON, Object inParamRecordList)
   at ssWEB.RssExtensionardoJSON.MssJSON2RecordList(HeContext heContext, String inParamJSON, Object inParamRecordList)
   at ssWEB.Actions.ActionJSON2RecordList(HeContext heContext, String inParamJSON, Object inParamRecordList)
   at ssWEB.Flows.FlowReferences.ScrnDocument_Popup_JSON.CommandSave(HeContext heContext)

What could be causing it ? 

Regards
Hi Kota,

Can you post an espace with the structures and a sample json that you are trying to load?
Would be great if you could do a little sample espace that replicates the problem.

Regards,
João Rosado
Hi Joao, 
              Please find attached a sample e-space with same problem. 

Regards
any updates on this one ?
Hi kota,

Sorry for the delay, didn't notice your previous post.

The problem happens because your structure does not match the json.
Well, actually 2 problems. So lets go step by step.

Your json is something simplified to [  [ "123", "1663" ], [ "456", "1663" ] ]
That textually it a List ( "[" ) of a List ( "[" ) of Texts ( "123").

So assuming your variable will be a RecordList (taking care of the first level) your structures need to look like this:


Where ListOfTexts.Value is a RecordList of TextStructure


And TextStructure.Value is a Text



This leads to what was actually causing the null pointer.
Your attribute name in lists needs to be called "Value"! I don't know why ..had to go dig in the code to find that was the problem. Even though it says in the documentation post (but it was not obvious ..and I'll make sure to complain to the author of the extension tomorrow :P)

http://www.outsystems.com/forums/discussion/10218/documentation/
"If the JSON data is a basic type and the Record contains an attribute named Value which matches the type, a record will be added to it."


Regards,
João Rosado




Yes, the Value thingy is (in hindsight) a regrettable design decision.

an upcoming version 2.0 of ardoJSON with breaking changes might change this.
João Rosado wrote:
Hi kota,

Sorry for the delay, didn't notice your previous post.

The problem happens because your structure does not match the json.
Well, actually 2 problems. So lets go step by step.

Your json is something simplified to [  [ "123", "1663" ], [ "456", "1663" ] ]
That textually it a List ( "[" ) of a List ( "[" ) of Texts ( "123").

So assuming your variable will be a RecordList (taking care of the first level) your structures need to look like this:


Where ListOfTexts.Value is a RecordList of TextStructure


And TextStructure.Value is a Text



This leads to what was actually causing the null pointer.
Your attribute name in lists needs to be called "Value"! I don't know why ..had to go dig in the code to find that was the problem. Even though it says in the documentation post (but it was not obvious ..and I'll make sure to complain to the author of the extension tomorrow :P)

http://www.outsystems.com/forums/discussion/10218/documentation/
"If the JSON data is a basic type and the Record contains an attribute named Value which matches the type, a record will be added to it."


Regards,
João Rosado



 
 Thanks Joao, I would never have figured out its working specially , attribute name need to be "Value". Thanks Again.