Failed to deserialize JSON

  

Hello,

I'm trying to open a GeoJSON to test in Outsystems from the following link:

https://raw.githubusercontent.com/johan/world.geo.json/master/countries.geo.json

i set up as a REST action, but i get this error everytime

I've tried stuff from a lot of posts about this subject on the forums, but can't seem to get it to work

This is the error message:


any help is appreciated

Hi Miguel, 

I know its frustrating with stuff like this, but can you show more information for example like the flow picture to understand more about what may cause the error here. 


Hope you get the help needed 

Cheers,
Mohamed AlMokadem

Hi Miguel,

I'm getting the same... looks like it's some character being returned or something.

Gonna look into it a little bit more.


Edit: Or like Kilian as said. It maybe the JSON structure. Although Service Studio didn't complain about it.

João,

That's interesting errors you are getting, they are different from the ones Miguel or I have. Are you sure you have the correct JSON?

I've attached my version to this post.


João,

You gotta explain what you did there :). What's the __singleArrayAttribute thing? Some hidden feature?

Kilian Hekhuis wrote:

João,

You gotta explain what you did there :). What's the __singleArrayAttribute thing? Some hidden feature?

I didn't even noticed that :D


So the steps I took were these:

1. Add Single Method


2. Paste the URL that Miguel gave and Test


3. Copy to response body and it was it!

4. Call the method in a test screen 

That explains. I just copy/pasted a subset of the data directly into a JSON Deserialize node, and got into all kinds of problems. Apparently it's a hidden feature...

Mohamed ElMokadem wrote:

Hi Miguel, 

I know its frustrating with stuff like this, but can you show more information for example like the flow picture to understand more about what may cause the error here. 


Hope you get the help needed 

Cheers,
Mohamed AlMokadem


Im sorry, it didn't seem too important because the only thing there is the API call for the URL i provided, you can see João Heleno's example above on how to replicate it.


Thank you,


Miguel Pereira

João Heleno wrote:

Kilian Hekhuis wrote:

João,

You gotta explain what you did there :). What's the __singleArrayAttribute thing? Some hidden feature?

I didn't even noticed that :D


So the steps I took were these:

1. Add Single Method


2. Paste the URL that Miguel gave and Test


3. Copy to response body and it was it!

4. Call the method in a test screen 

this is indeed how to do it, and you get the same problem as i'm getting. It really seems the problem is with the structure created by the Platform. I've tried using ardoJSON, aswell as trying to change the response format, but nothing works, since the problem is the structure


I have also tried with this URL:

https://storage.googleapis.com/maps-devrel/google.json

and it works without any issue, since the structure is read properly.


Thank you for the help,

Miguel Pereira


Ah, I now see what the problem is, and the error message gives you exactly the position where it goes wrong. Line 3 has geometry type "MultiPolygon", which adds another level of array. So the structures created by the platform are based on the 2nd line, which has type "Polygon" and has three levels, and it encounters the 3rd line which has four. That's not gonna work for the Platform. Don't know whether that can be solved without an OnAfterResponse and some nasty post-processing.


Solution

Ok, here's a solution. A bit clunky and inefficient, but it gets the job done.

Solution

Nice one Kilian!

@Miguel

Please notice that Kilian's solution was customising the response using the OnAfterResponse callback action.

More info here: https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/REST/Consume_REST_APIs/Simple_Customizations

Yeah, forgot to mention that :). Also, it changes the 3-depth array to a 4-depth array so that everything is 4-depth, but since the closing array tags can't be uniquely identified for 3 and 4-depth, everything gets an extra level, but then the now 5 closing ] must be restored to 4. Like I said, a bit clunky, but it's performant enough I noticed.

Kilian Hekhuis wrote:

Ok, here's a solution. A bit clunky and inefficient, but it gets the job done.


Thank you so much!!!

João Heleno wrote:

Nice one Kilian!

@Miguel

Please notice that Kilian's solution was customising the response using the OnAfterResponse callback action.

More info here: https://success.outsystems.com/Documentation/10/Extensibility_and_Integration/REST/Consume_REST_APIs/Simple_Customizations

i tried messing around with it before, but since i'm a bit new to outsystems and even more to any kind of JSON objects couldn't get it to work.


Thank you aswell for the help!


Hi Miguel,

Glad I could be of help. OutSystems is sometimes a bit picky what it excepts in terms of JSON, but with the OnAfterResponse you can often get it to work with a bit of effort. Happy coding!