Handling Links in JSON

Michael Holleran

The CA Live API Creator team has been working on our handling of links, and a lot of question have arisen. There is a lot of confusion over how to represent links.

One possibility:

"customer" : "http://rest.logicbeam.com/v1/customer/123"

The problem with that is that it's not immediately obvious to a program that this is a link (it could be a piece of text that just happens to be a URI), and even worse, this tells us nothing about what's on the other side of this link, or how we're related to it.
Another possibility is to have composite links, e.g.:

{
"href " : "http://rest.logicbeam.com/v1/employee/456",
"rel" : "owner",
"title" : "Owner",
"type" : "http://rest.logicbean.com/v1/employee"
}

This is much more descriptive, although there is still a lot of uncertainty regarding the "proper" values for rel and type.

There is in fact a registry of "legal" values for the rel attribute, but a quick look at it should convince you that it's not all that useful in a REST/JSON context.
It's become quite common for JSON objects to include a links section, for example:

{
"name" : "Billy Bob's bait shop",
"address" : "123 Main st, Anytown, USA"
"links" : [
{
"href" : "http://rest.logicbeam.com/v1/employee/456",
"rel" : "owner",
"title" : "Owner",
"type" : "http://rest.logicbean.com/v1/employee"
}
]
}

This makes it very clear, but it's also rather verbose.
http://www.mnot.net/blog/2011/11/25/linking_in_json

Chat
What would you like to chat about?
Support
Contact
Call us at 1-800-225-5224
Call us at 1-800-225-5224
Contact Us

Chat with CA

Just give us some brief information and we'll connect you to the right CA ExpertCA sales representative.

Our hours of availability are 8AM - 5PM CST.

All Fields Required

connecting

We're matching your request.

Unfortunately, we can't connect you to an agent. If you are not automatically redirected please click here.

  • {{message.agentProfile.name}} will be helping you today.

    View Profile


  • Transfered to {{message.agentProfile.name}}

    {{message.agentProfile.name}} joined the conversation

    {{message.agentProfile.name}} left the conversation

  • Your chat with {{$storage.chatSession.messages[$index - 1].agentProfile.name}} has ended.
    Thank you for your interest in CA.


    Rate Your Chat Experience.

    {{chat.statusMsg}}

agent is typing