Adjusting response format

Adjusting response format

As a response Allele Registry returns a single JSON object or an array of JSON objects. If URL from a HTTP request does not specify a protocol, returned JSON content is formatted in user-friendly way. When protocol is set to json, returned JSON objects are compressed in single lines without any unnecessary white spaces. If a response consists of an array of objects, each object is saved in separate line. First line starts from ‘[‘ character, following lines start from ‘,’ character and the last line consists of single ‘]’ character.

The content of a response can be controlled by optional parameter fields. It can have one of the following values:

  • fields=none[+|-field][+|-field][+|-field]…
  • fields=all[+|-field][+|-field][+|-field]…

The first version (none) corresponds to empty documents to which we can add expected fields, e.g:

fields=none+@id+externalRecords.dbSNP.rs

means that returned documents are going to contain only fields @id and externalRecords.dbSNP.rs. The rest of document content will be omitted. The second version of field parameter (all) starts from full document structure and allow to modify content of the response by cutting of (“subtract”) unwanted fields. Both these expressions are always parsed from left to right, what allows for defining more complicate rules, e.g.:

fields=none+externalRecords­externalRecords.dbSNP

is going to return documents with structure externalRecords, but without nested structure dbSNP.