Last active
February 8, 2016 22:18
-
-
Save landlessness/9d4f035339469510de9d to your computer and use it in GitHub Desktop.
Nested Sub-Entities Under a Collection Approach 2 : Siren for Ruby's ActiveModelSerializer
This file contains hidden or 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
{ | |
"class": ["post"], | |
"properties": { | |
"id": 1, | |
"title": "New Post", | |
"body": "Body" | |
}, | |
"links": [{"rel": ["self"],"href": "http: //example.com/posts/1"}], | |
"entities": [ | |
{ | |
"class": ["tags","collection"], | |
"rel": ["http: //rels.example.com/tags","hasMany"], | |
"links": [{"rel": ["self"], "href": "http://example.com/posts/1/tags"}], | |
"properties": {"count": 3} | |
}, | |
{ | |
"class": ["comments","collection"], | |
"rel": ["http: //rels.example.com/comments","hasMany"], | |
"links": [{"rel": ["self"], "href": "http://example.com/posts/1/comments"}], | |
"properties": {"count": 2} | |
} | |
] | |
} |
This file contains hidden or 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
{ | |
"class": ["post"], | |
"properties": { | |
"id": 1, | |
"title": "New Post", | |
"body": "Body" | |
}, | |
"links": [{"rel": ["self"],"href": "http: //example.com/posts/1"}], | |
"entities": [ | |
{ | |
"class": ["tags","collection"], | |
"rel": ["http: //rels.example.com/tags","hasMany"], | |
"links": [{"rel": ["self"], "href": "http://example.com/posts/1/tags"}], | |
"properties": {"count": 3} | |
}, | |
{ | |
"class": ["comments","collection"], | |
"rel": ["http: //rels.example.com/comments","hasMany"], | |
"links": [{"rel": ["self"], "href": "http://example.com/posts/1/comments"}], | |
"properties": {"count": 2}, | |
"entities": [ | |
{ | |
"class": ["comment"], | |
"rel": ["http: //rels.example.com/comment"], | |
"properties": {"id": 1, "body": "ZOMG A COMMENT"}, | |
"links": [{"rel": ["self"],"href": "http: //example.com/comments/1"}], | |
"actions": [ | |
{"name": "delete", "method": "DELETE", "href": "http://example.com/comments/1"}, | |
{"name": "update", "method": "PATCH", "href": "http://example.com/comments/1", "fields": [ {"name": "body" }]}] | |
}, | |
{ | |
"class": ["comment"], | |
"rel": ["http: //rels.example.com/comment"], | |
"properties": {"id": 2, "body": "ZOMG ANOTHER COMMENT"}, | |
"links": [{"rel": ["self"],"href": "http: //example.com/comments/2"}], | |
"actions": [ | |
{"name": "delete", "method": "DELETE", "href": "http://example.com/comments/2"}, | |
{"name": "update", "method": "PATCH", "href": "http://example.com/comments/2", "fields": [ {"name": "body" }]}] | |
} | |
] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment