Which JSON structure correctly uses link relations to represent these?
hard📝 Application Q15 of 15
Rest API - HATEOAS and Linking
You want to design a REST API response for a blog post that includes links to the post itself, the author's profile, and comments. Which JSON structure correctly uses link relations to represent these?
Each link relation should be an object with an 'href' key inside the '_links' object.
Step 2: Evaluate each option's structure
{ "_links": { "self": { "href": "/posts/10" }, "author": { "href": "/users/5" }, "comments": { "href": "/posts/10/comments" } } } correctly uses '_links' with 'self', 'author', and 'comments' keys, each having an 'href' URL. Options B and D use 'url' instead of 'href', and C uses strings instead of objects.