Deserializing Compound Documents

Hey everyone, I’m using JSON:API for my back-end and the mobile app client needs to deserialize the compound document responses as efficiently and fast as possible. I’m used to deserializing API responses that have an object structure where the relationships are directly mapped to the primary data with key value pairs. But with compound documents, the related resources are in a separate ‘included’ array. It appears to be inefficient to use the ids of the resources in the relationships object to search for the full resource object that I need to load into the app. Are there good libraries or approaches that you all have used for efficient and fast deserialization of compound documents?

There is a list of client-side implementations here: JSON:API — Implementations

I agree that searching is not an efficient approach. It scales better if you parse the document top to bottom and establish the relationships as soon as they are declared.

Please mind that a referenced resource may or may not be included in the compound document.

A good client-side implementation should take care of that for you.

1 Like

I might try sarala-json-api-data-formatter or json-api-models because they are lightweight and framework agnostic. I’m just worried about how stable these libraries are and whether they are compliant with the latest version of JSON:API.