Paul's Programming Notes PostsRSSGithub

JSON-API - Lessons Learned

A few things I’ve learned while building against JSON-API:

  • Objects referred to by relationships all go into one shared included array rather than being nested under the relationship that points at them. Without a JSON-API client library that’s a slight pain to parse, because you’re matching type and id pairs back to entries in a flat list. It beats duplicating the same object under every relationship that refers to it, but I would have preferred each object type under its own top level key.
  • It’s a lot more verbose than a response you’d shape by hand. Every record carries type, id, attributes, and relationships wrappers around what would otherwise be a flat object.
  • There’s no PUT. The spec uses PATCH for updates, so you send only the fields that changed instead of replacing the whole resource.