Deserializing GeoJson Response

I’m having some difficulty extracting coordinate data from the geoJson response, when I make a call to “get planning area”.
I have done the following: after receiving response from onemap api, I parse it as a string. After that, I have tried using Newtonsoft JSON.Net to deserialize the string into an object of type “geojson”. I have made the geojson response class, although it is probably wrong.
I’m wondering if anyone has written a class for various geojson response types (eg multipolygon) from this api, and if so could they please share some insight.

Thanks,

Nate

Update

I’ve come up with a workaround which relies on de-serializing the json response in two separate instances. This is due to the formatting of the json response from oneMap. Looking at this sample response, you can see that the geojson (with the coordinates) contained within the overall json response is surrounded with quotes:

[ {“pln_area_n”: “QUEENSTOWN”,“geojson”: "{“type”:“MultiPolygon”,“coordinates”:[[[[103.802283981872,1.30724221295973],[103.802425275872,1.30723324251248],[103.802425416944,1.30723323166185], [103.802458961548,1.3072307152304],[103.802652599571,1.30721836399803],[103.802696566049,1.3071728668585],[103.803189909937,1.30671929783162],[103.803283706296,1.30651729103507], [103.803508863524,1.30558818387374],[103.803555843427,1.30411268276738],[103.803574359692,1.30396638663125],[103.803622995749,1.30354546967306],[103.803856417354,1.30254212053914], [103.804124982262,1.30196506125208],[103.804803771942,1.3004823930227],[103.805123881249,1.30040789688888],[103.805105908234,1.3003555050315],[103.805889814255,1.30018357681829], [103.805905135703,1.30023369868607],[103.805908743234,1.30024549978044],[103.806263580325,1.30017300071634],[103.806326784411,1.30013228961175],[103.806422855741,1.30006613274865], [103.806498700633,1.30001778712831],[103.806579602452,1.29997707530201],[103.806680728717,1.2999363636879],[103.807065010095,1.29987020984425],[103.807156023758,1.2998651219351], [103.807277375759,1.29987275694056],[103.807436648869,1.29989820379476],[103.807679787396,1.29995077882159],[103.807699168777,1.29988470975123],[103.807731733404,1.29974967305778]…

This means it will be recognized merely as a string. You need therefore need to make two json response classes and then deserialize accordingly.

Hi Hartwig,

You have to extract the JSON for the geojson string. After which, I believe you could use this GeoJSON library for deserialisation.

Regards,
Kai