Crunch API endpoints do not return plain old javascript objects (POJOs) directly but instead deliver POJOs inside a property of machine-readable custom envelopes that facilitate endpoint exploration and traversal. See the envelope spec to learn more.
Using crunch API envelopes can be summarized like this:
let data = {}
switch (response.element) {
case 'shoji:entity':
data = response.body
break
case 'shoji:catalog':
data = response.index
break
case 'shoji:view':
data = response.value
break
}
ENTITY envelope
A Shoji entity is identified by element: "shoji:entity". Its principal attribute is the body key, which is an object containing the attributes that describe the entity.
CATALOG envelope
A catalog is identified by element: "shoji:catalog" with its principal attribute being index that contains an object keyed by the URLs of the entities it contains and for each key an object (tuple) with attributes from the referenced entity.
Shoji catalogs are not ordered. For its ordered representations they may provide an orders set of Shoji order resources.
VIEW envelope
A Shoji view is identified by element: "shoji:view" with its principal attribute being value. This can contain any arbitrary JSON object.
ORDER envelope
Shoji orders are identified by element: "shoji:order". The principal attribute is the graph key which is an array containing the order of present resources.
A shoji order may be associated with a catalog. In such case it will contain a subset or totality of the entities present in the catalog. The catalog remains as the authoritative source of available entities.
Any entity not present on the order but present in the catalog may be considered to belong at the bottom of the root of the graph in an arbitrary order, or may be excluded from view.