When you work with JSONAPI, how you handle the boolean attributes?
For example:
{
"type": "motors",
"id": "1",
"attributes": {
"name": "V8",
"working": "true"
}
}
or
{
"type": "motors",
"id": "1",
"attributes": {
"name": "V8",
"working": "1"
}
}
Also, I think this is better solution, but don't work with the official specification:
{
"type": "motors",
"id": "1",
"attributes": {
"name": "V8",
"working": true
}
}
The first two examples represent strings
and the last example represents a boolean
value on JSON (http://www.json.org/)
From the spec:
A value can be a string in double quotes
, or a number
, or true
or false
or null
, or an object
or an array
. These structures can be nested.`
If you really want a boolean
then use the last example.
JSON:API
do not say anything about it because, the specification itself is on top of JSON
(inherit all the JSON
specification)