Created
February 18, 2012 02:19
-
-
Save treyhunner/1856954 to your computer and use it in GitHub Desktop.
Embedding links in HAL+JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"queue_status": "running", | |
"_embedded": { | |
"jobs": [ | |
{ | |
"_links": { | |
"self": { "href": "/queue/job1" }, | |
} | |
"status": "queued" | |
}, | |
{ | |
"_links": { | |
"self": { "href": "/queue/job2" }, | |
} | |
"status": "running" | |
}, | |
{ | |
"_links": { | |
"self": { "href": "/queue/job2" }, | |
"output": { "href": "/output2" } | |
} | |
"status": "complete" | |
} | |
] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"queue_status": "running", | |
"jobs": [ | |
{ | |
"_links": { | |
"self": { "href": "/queue/job1" }, | |
} | |
"status": "queued" | |
}, | |
{ | |
"_links": { | |
"self": { "href": "/queue/job2" }, | |
} | |
"status": "running" | |
}, | |
{ | |
"_links": { | |
"self": { "href": "/queue/job2" }, | |
"output": { "href": "/output2" } | |
} | |
"status": "complete" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So the difference is:
Although _embedded may seem like noise, it's valuable to have HAL defined this way because it allows generic libraries/browsers to be written that can efficiently distinguish embedded resources from standard JSON properties that belong to the resource.