Nested query params

Darius JJ Chuck

2021-06-02

There are many ways to encode lists and nested structures in query params. For example like this1:

?include=author&fields[articles]=title,body&fields[people]=name HTTP/1.1

A more-or-less equivalent JSON:

{
  "include": "author",
  "fields": {
    "articles": ["title", "body"],
    "people": ["name"]
  }
}

How could that look in Data TAO?

include [author]
fields [
  articles [[title][body]]
  people [[name]]
]

More compactly:

include[author]fields[articles[[title][body]]people[[name]]]

There is an even more compact way that is still TAO, but not strictly Data TAO.

Point is: an extremely minimal syntax like TAO can fit in all the contexts that JSON, XML, or other less minimal syntaxes can, as well as in contexts where they are impractical. Thus the syntax is more universal and there is no need to invent, parse, and translate any error-prone ad-hoc solutions. Incidental complexity is reduced.


  1. Example from the JSON API spec↩︎