Error Deserializing JSON Response

Error Deserializing JSON Response

  

Hi, I'm consuming a WS which; at the botton has some "dictionary" on then form

{
"dictionaries": {
"currencies": {
"USD": "US DOLLAR"
},
"aircraft": {
"717": "BOEING 717",
"738": "BOEING 737-800"
},
"locations": {
"DFW": {
"subType": "AIRPORT",
"detailedName": "DALLAS FT WORTH INTL"
},
"ATL": {
"subType": "AIRPORT",
"detailedName": "HARTSFIELD-JACKSON INT"
}
}
}
}


this data is dynamic, sometimes is USD, sometimes ir EUR, sometimes is 717, and sometimes 718 and so on.

How can i parse this JSON without using an Advance onAfterResponse over the WS ??


Regards.

Solution

Hi Roberto,


You can use the ardoJSON extension from the forge. It has a method to convert the "dictionary" attributes into a list of key/value structures.


Regards,

João Rosado

Solution

Hi Roberto Demestri,

I reviewed your JSON .Since your JSON is created dynamically( as you mentioned ). Means you don't have any fixed column . We cannot convert your json to list as Outsystems required fixed structure to work on. Please find the screen shot for more information.

This is what I have witnessed till now .If you find any method where your can perform the same operation using dynamic json data , please do let me know.

JSON Formatter  :- https://jsonformatter.curiousconcept.com/

Happy Coding :)

Like I said on my reply there is an action in ardoJSON to do it.


You use it in your OnAfterResponse callback and it can transform the RequestText to replace all the "Dictionary" attributes with lists of name/value pairs.


If you need to replace multiple attributes you may need to call the method multiple times (one for each attribute) 

In your case Path argument should be something like "dictionaries.currencies", "dictionaries.locations", ...


I sugest creating a page where you pass an example of your text, do all the replacements and display the result.

Then use the result text as an example in the REST API window and let Service Studio create all the structures for you. Then add the OnAfterResponse method with the same transformations you did on the test page.


Regards,
João Rosado

João Rosado wrote:

Like I said on my reply there is an action in ardoJSON to do it.


You use it in your OnAfterResponse callback and it can transform the RequestText to replace all the "Dictionary" attributes with lists of name/value pairs. Then you just need to 

If you need to replace multiple attributes you may need to call the method multiple times (one for each attribute) 

In your case Path argument should be something like "dictionaries.currencies", "dictionaries.locations", ...


I sugest creating a page where you pass an example of your text, do all the replacements and display the result.

Then use the result text as an example in the REST API window and let Service Studio create all the structures for you. Then add the OnAfterResponse method with the same transformations you did on the test page.


Regards,
João Rosado


Thanks for the update . I missed that :)