Bird
0
0

Which of the following is the correct JSON syntax for a HAL link to a 'self' resource?

easy📝 Syntax Q3 of 15
Rest API - HATEOAS and Linking
Which of the following is the correct JSON syntax for a HAL link to a 'self' resource?
A"_links": { "self": { "href": "/orders/123" } }
B"_links": { "self": "/orders/123" }
C"_links": { "href": { "self": "/orders/123" } }
D"_links": { "self": ["/orders/123"] }
Step-by-Step Solution
Solution:
  1. Step 1: Recall HAL link syntax

    HAL requires links to be objects with an href property inside _links. So "self": { "href": "/orders/123" } is correct.
  2. Step 2: Check other options for syntax errors

    "_links": { "self": "/orders/123" } uses a string directly instead of an object. "_links": { "href": { "self": "/orders/123" } } reverses keys incorrectly. "_links": { "self": ["/orders/123"] } uses an array which is invalid here.
  3. Final Answer:

    "_links": { "self": { "href": "/orders/123" } } -> Option A
  4. Quick Check:

    HAL link = object with href [OK]
Quick Trick: HAL links always use an object with href property [OK]
Common Mistakes:
  • Using string instead of object for links
  • Misplacing href key
  • Using arrays instead of objects for links

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes