Some json configurations will emit a single root node named after the object's type or an abstractable name for the object depending on context. This document outlines the differences and examples of both included and discluded root nodes in JSON responses.
Nodes of this type, for request GET foos
will respond with this body:
{
"foo": {
"bar": "baz"
}
}
Responses that do not respond with a root node will, for request GET foos
, respond with this body:
{
"bar": "baz"
}
Responses involving nested resources will not emit those nested resources' root nodes, however:
{
"bar": "baz",
"herp": {
"derp": "yerp"
}
}
Collection requests are configured similarly. Assuming that a root node name can be derived from classname (being the same for all items in the collection) or from an abstracted name (such as 'items'), a response body for request GET foos
is formatted:
{
"foos": [
{
"bar": "baz"
},
{
"bar": "derp"
}
]
}
For a response not providing a root node, a response body for request GET foos
is formatted:
[
{
"bar": "baz"
},
{
"bar": "derp"
}
]
Hi,
i want json response like this format
"foos": [
{
"bar": "baz"
},
{
"bar": "derp"
}
]
}
but i don't kown...