Given a GeoJSON object:
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands"
}
}
and a corresponding Place
model:
{
"data": {
"id": "123",
"type": "places",
"attributes": {
"name": "Dinagat Islands",
"geometry": "POINT(125.6 10.1)"
},
},
"links": {
"self":"https://api.example.net/places/123"
},
"jsonapi": {
"version": "1.0"
}
}
How to represent GeoJSON objects in a JSONAPI stream?
- First option is, as above, to not represent the GeoJSON object and let the client figure it out.
- Second option is to represent the GeoJSON object embedded into the JSONAPI resource:
{ "data": { "id": "123", "type": "places", "attributes": { "type": "Feature", "geometry": { "type": "Point", "coordinates": [125.6, 10.1] }, "properties": { "name": "Dinagat Islands" } } }, "links": { "self":"https://api.example.net/places/123" }, "jsonapi": { "version": "1.0" } }
- or even, embedded as part of a representation of the resource:
{ "data": { "id": "123", "type": "places", "attributes": { "name": "Dinagat Islands", "geometry": "POINT(125.6 10.1)", "geojson": { "type": "Feature", "geometry": { "type": "Point", "coordinates": [125.6, 10.1] }, "properties": { "name": "Dinagat Islands" } } } }, "links": { "self":"https://api.example.net/places/123" }, "jsonapi": { "version": "1.0" } }
- etc. (can include usage of
meta
…)
Is there an example of working JSONAPI serving GeoJSON resources?