This is the first time we are using JSON API in our projects and according to specification on their web, this is what a regular JSON API response should look like
I don’t think the specification explicitly forbids that, but in your case I would make location a relationship. I would make your API for flexible. For example, you could retrieve a list of articles written about a certain place with /locations/id/articles.
Yes the specification allows nested complex types in attributes of an individual resource, BUT the complex type can not be another resource. See for example Clarification on Resources Composed of Other Resources in the json:api forum for details on this topic. If the nested type is another resource, favor a relationship instead. A corollary to this is do not include “foreign keys” in resources, again instead favor relationships between resources that abstract foreign keys away.
From a purely design perspective (bike shedding here we GO!) I would say you would be able to do this for a string location perhaps, but I’m not sure how helpful the sub resources would be at /location/-33.234235,151.247592/…etc
I am facing the same issue @junkoo. I am thinking of keeping the same format in the nested (non-resource) object, i.e type, attributes, and relationships, simply because in my use case, the nested non-resource object can have resource objects as relationships of its own! I’m not sure the spec covers this use case, but I’m pretty sure it doesn’t expressly forbid it.