Deserialize GeoJSON string to FeatureCollection structure

Hi all,

{ "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "name": "test", "zoom": "7", "centroid": [0,0] }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -9.135766001562493, 37.40206689463959 ], [ -6.850609751562493, 36.973202804029675 ], [ -9.146752329687493, 36.85022336332111 ], [ -9.135766001562493, 37.40206689463959 ] ] ] } } ] }

Basically, I have two API methods GET and POST both using the same FeatureCollection structure, as payload for the POST and as output for the GET. For some reason the platform is able to parse the output of the GET API to my FeatureCollection structure, but is not being able to deserialize the JSON string above that I build using gmaps/javascript, to the same FeatureCollection structure using the deserialize action from the platform.

I'm getting this error

"Failed to deserialize JSON to FeatureCollection: Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'ssSignalUsers.RestRecords.JSONSTCoordinateItemStructure' because the type requires a JSON object (e.g. {""name"":""value""}) to deserialize correctly. To fix this error either change the JSON to a JSON object (e.g. {""name"":""value""}) or change the deserialized type to an array or a type that implements a collection interface  (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array. Path 'features[0].geometry.coordinates[0]', line 1, position 113."

Since i'm using the standard GeoJSON format I cannot change it. Do anyone have an idea how to deserialize a JSON string like the one above in the platform? Also, I would like to understand why the platform is able to parse the response of the API to the structure and it fails when I try to deserialize using the built-in deserialize action (same JSON)?



Hi Severiano Melo,

I had an error similar to this and I had to handle it manually.

  1. Each element will always check if it is an array or not.

  2. If it is an array, check whether it is a two-dimensional array or a three-dimensional array.

  3. After that, features[""0""].geometry >> features[0].geometry

For example: In my case, JSON has three-dimensional array:


Did you figure out how to do this without text processing? I'm also facing the same issue while deserializing and creating a geojson.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.