Quiz Yourself: Building JSON
Test your knowledge of how to modify the JSON output of a Rails application.
We'll cover the following...
We'll cover the following...
Technical Quiz
1.
Which of the following snippets is a valid JSON response with product’s user
into an include
section and product_id
as a
relationship?
A.
{
"data": [
{
"id": 1, "type": "product", "attributes": {
"user": {
"id": 2, "attributes": { "email": "stephany@lind.co.uk" }
}
}
}
]
}
B.
{
"data": [
{
"id": 1, "type": "product", "relationships": {
"user": { "id": 2, "type": "user" }
}
}
],
"include": [
{
"id": 2, "type": "user", "attributes": { "email": "stephany@lind.co.uk" }
}
]
}
C.
{
"data": [
{ "id": 1, "title": "First product", "user_id": 2 }
],
"include": [
{
"id": 2, "type": "user",
"attributes": { "email":
"stephany@lind.co.uk" }
}
]
}
1 / 3
...