From f8f79355358a1d61b24f4c1350a923b36733a143 Mon Sep 17 00:00:00 2001 From: Benjamin Fleischer Date: Fri, 13 Oct 2017 22:00:43 -0500 Subject: [PATCH] Assert no regressions in gem-specific JSON document NOTE: the two gems are generating different JSON Essential difference - Including a user's posts's comments differ in that the included resource's relationship is `meta: {included: false}` instead of `data: { id: 20, type: :posts}` ```diff id: 39, type: comments attributes: { author: me, comment: wazzup } relationships: { post: { - data: { id: 20, type: posts } + meta: { included: false } } } } ``` Unimportant differences: - data: { type, id } vs. data: { id, type } Complete diff ```bash diff --side-by-side support/json_document-ams.json support/json_document-jsonapi_rb.json ``` ```diff { { "data": { "data": { "id": "1", "id": "1", "type": "users", "type": "users", "attributes": { "attributes": { "first_name": "Diana", "first_name": "Diana", "last_name": "Prince", "last_name": "Prince", "birthday": "2017-07-01 05:00:00 UTC", "birthday": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC", "updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "posts": { "posts": { "data": [ "data": [ { { "id": "1", | "type": "posts", "type": "posts" | "id": "1" }, }, { { "id": "2", | "type": "posts", "type": "posts" | "id": "2" }, }, { { "id": "3", | "type": "posts", "type": "posts" | "id": "3" }, }, { { "id": "4", | "type": "posts", "type": "posts" | "id": "4" }, }, { { "id": "5", | "type": "posts", "type": "posts" | "id": "5" }, }, { { "id": "6", | "type": "posts", "type": "posts" | "id": "6" }, }, { { "id": "7", | "type": "posts", "type": "posts" | "id": "7" }, }, { { "id": "8", | "type": "posts", "type": "posts" | "id": "8" }, }, { { "id": "9", | "type": "posts", "type": "posts" | "id": "9" }, }, { { "id": "10", | "type": "posts", "type": "posts" | "id": "10" }, }, { { "id": "11", | "type": "posts", "type": "posts" | "id": "11" }, }, { { "id": "12", | "type": "posts", "type": "posts" | "id": "12" }, }, { { "id": "13", | "type": "posts", "type": "posts" | "id": "13" }, }, { { "id": "14", | "type": "posts", "type": "posts" | "id": "14" }, }, { { "id": "15", | "type": "posts", "type": "posts" | "id": "15" }, }, { { "id": "16", | "type": "posts", "type": "posts" | "id": "16" }, }, { { "id": "17", | "type": "posts", "type": "posts" | "id": "17" }, }, { { "id": "18", | "type": "posts", "type": "posts" | "id": "18" }, }, { { "id": "19", | "type": "posts", "type": "posts" | "id": "19" }, }, { { "id": "20", | "type": "posts", "type": "posts" | "id": "20" } } ] ] } } } } }, }, "included": [ "included": [ { { "id": "1", "id": "1", "type": "posts", "type": "posts", "attributes": { "attributes": { "title": "Some Post", "title": "Some Post", "body": "awesome content", "body": "awesome content", "created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC", "updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "user": { "user": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, }, "comments": { "comments": { "data": [ "data": [ { { "id": "1", | "type": "comments", "type": "comments" | "id": "1" }, }, { { "id": "2", | "type": "comments", "type": "comments" | "id": "2" } } ] ] } } } } }, }, { { "id": "1", | "id": "2", "type": "comments", | "type": "posts", "attributes": { "attributes": { "author": "me", | "title": "Some Post", "comment": "nice blog" | "body": "awesome content", > "created_at": "2017-07-01 05:00:00 UTC", > "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "post": { | "user": { "data": { | "meta": { "id": "1", | "included": false "type": "posts" < } } > }, > "comments": { > "data": [ > { > "type": "comments", > "id": "3" > }, > { > "type": "comments", > "id": "4" > } > ] } } } } }, }, { { "id": "2", | "id": "3", "type": "comments", | "type": "posts", "attributes": { "attributes": { "author": "me", | "title": "Some Post", "comment": "nice blog" | "body": "awesome content", > "created_at": "2017-07-01 05:00:00 UTC", > "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "post": { | "user": { "data": { | "meta": { "id": "1", | "included": false "type": "posts" < } } > }, > "comments": { > "data": [ > { > "type": "comments", > "id": "5" > }, > { > "type": "comments", > "id": "6" > } > ] } } } } }, }, { { "id": "2", | "id": "4", "type": "posts", "type": "posts", "attributes": { "attributes": { "title": "Some Post", "title": "Some Post", "body": "awesome content", "body": "awesome content", "created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC", "updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "user": { "user": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, }, "comments": { "comments": { "data": [ "data": [ { { "id": "3", | "type": "comments", "type": "comments" | "id": "7" }, }, { { "id": "4", | "type": "comments", "type": "comments" | "id": "8" } } ] ] } } } } }, }, { { "id": "3", | "id": "5", "type": "comments", | "type": "posts", "attributes": { "attributes": { "author": "me", | "title": "Some Post", "comment": "nice blog" | "body": "awesome content", > "created_at": "2017-07-01 05:00:00 UTC", > "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "post": { | "user": { "data": { | "meta": { "id": "2", | "included": false "type": "posts" < } } > }, > "comments": { > "data": [ > { > "type": "comments", > "id": "9" > }, > { > "type": "comments", > "id": "10" > } > ] } } } } }, }, { { "id": "4", | "id": "6", "type": "comments", | "type": "posts", "attributes": { "attributes": { "author": "me", | "title": "Some Post", "comment": "nice blog" | "body": "awesome content", > "created_at": "2017-07-01 05:00:00 UTC", > "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "post": { | "user": { "data": { | "meta": { "id": "2", | "included": false "type": "posts" < } } > }, > "comments": { > "data": [ > { > "type": "comments", > "id": "11" > }, > { > "type": "comments", > "id": "12" > } > ] } } } } }, }, { { "id": "3", | "id": "7", "type": "posts", "type": "posts", "attributes": { "attributes": { "title": "Some Post", "title": "Some Post", "body": "awesome content", "body": "awesome content", "created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC", "updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "user": { "user": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, }, "comments": { "comments": { "data": [ "data": [ { { "id": "5", | "type": "comments", "type": "comments" | "id": "13" }, }, { { "id": "6", | "type": "comments", "type": "comments" | "id": "14" } } ] ] } } } } }, }, { { "id": "5", | "id": "8", "type": "comments", | "type": "posts", "attributes": { "attributes": { "author": "me", | "title": "Some Post", "comment": "nice blog" | "body": "awesome content", > "created_at": "2017-07-01 05:00:00 UTC", > "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "post": { | "user": { "data": { | "meta": { "id": "3", | "included": false "type": "posts" < } } > }, > "comments": { > "data": [ > { > "type": "comments", > "id": "15" > }, > { > "type": "comments", > "id": "16" > } > ] } } } } }, }, { { "id": "6", | "id": "9", "type": "comments", | "type": "posts", "attributes": { "attributes": { "author": "me", | "title": "Some Post", "comment": "nice blog" | "body": "awesome content", > "created_at": "2017-07-01 05:00:00 UTC", > "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "post": { | "user": { "data": { | "meta": { "id": "3", | "included": false "type": "posts" < } } > }, > "comments": { > "data": [ > { > "type": "comments", > "id": "17" > }, > { > "type": "comments", > "id": "18" > } > ] } } } } }, }, { { "id": "4", | "id": "10", "type": "posts", "type": "posts", "attributes": { "attributes": { "title": "Some Post", "title": "Some Post", "body": "awesome content", "body": "awesome content", "created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC", "updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "user": { "user": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, }, "comments": { "comments": { "data": [ "data": [ { { "id": "7", | "type": "comments", "type": "comments" | "id": "19" }, }, { { "id": "8", | "type": "comments", "type": "comments" | "id": "20" } } ] ] } } } } }, }, { { "id": "7", | "id": "11", "type": "comments", | "type": "posts", "attributes": { "attributes": { "author": "me", | "title": "Some Post", "comment": "nice blog" | "body": "awesome content", > "created_at": "2017-07-01 05:00:00 UTC", > "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "post": { | "user": { "data": { | "meta": { "id": "4", | "included": false "type": "posts" < } } > }, > "comments": { > "data": [ > { > "type": "comments", > "id": "21" > }, > { > "type": "comments", > "id": "22" > } > ] } } } } }, }, { { "id": "8", | "id": "12", "type": "comments", | "type": "posts", "attributes": { "attributes": { "author": "me", | "title": "Some Post", "comment": "nice blog" | "body": "awesome content", > "created_at": "2017-07-01 05:00:00 UTC", > "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "post": { | "user": { "data": { | "meta": { "id": "4", | "included": false "type": "posts" < } } > }, > "comments": { > "data": [ > { > "type": "comments", > "id": "23" > }, > { > "type": "comments", > "id": "24" > } > ] } } } } }, }, { { "id": "5", | "id": "13", "type": "posts", "type": "posts", "attributes": { "attributes": { "title": "Some Post", "title": "Some Post", "body": "awesome content", "body": "awesome content", "created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC", "updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "user": { "user": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, }, "comments": { "comments": { "data": [ "data": [ { { "id": "9", | "type": "comments", "type": "comments" | "id": "25" }, }, { { "id": "10", | "type": "comments", "type": "comments" | "id": "26" } } ] ] } } } } }, }, { { "id": "9", | "id": "14", "type": "comments", | "type": "posts", "attributes": { "attributes": { "author": "me", | "title": "Some Post", "comment": "nice blog" | "body": "awesome content", > "created_at": "2017-07-01 05:00:00 UTC", > "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "post": { | "user": { "data": { | "meta": { "id": "5", | "included": false "type": "posts" < } } > }, > "comments": { > "data": [ > { > "type": "comments", > "id": "27" > }, > { > "type": "comments", > "id": "28" > } > ] } } } } }, }, { { "id": "10", | "id": "15", "type": "comments", | "type": "posts", "attributes": { "attributes": { "author": "me", | "title": "Some Post", "comment": "nice blog" | "body": "awesome content", > "created_at": "2017-07-01 05:00:00 UTC", > "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "post": { | "user": { "data": { | "meta": { "id": "5", | "included": false "type": "posts" < } } > }, > "comments": { > "data": [ > { > "type": "comments", > "id": "29" > }, > { > "type": "comments", > "id": "30" > } > ] } } } } }, }, { { "id": "6", | "id": "16", "type": "posts", "type": "posts", "attributes": { "attributes": { "title": "Some Post", "title": "Some Post", "body": "awesome content", "body": "awesome content", "created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC", "updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "user": { "user": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, }, "comments": { "comments": { "data": [ "data": [ { { "id": "11", | "type": "comments", "type": "comments" | "id": "31" }, }, { { "id": "12", | "type": "comments", "type": "comments" | "id": "32" } } ] ] } } } } }, }, { { "id": "11", | "id": "17", "type": "comments", | "type": "posts", "attributes": { "attributes": { "author": "me", | "title": "Some Post", "comment": "nice blog" | "body": "awesome content", > "created_at": "2017-07-01 05:00:00 UTC", > "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "post": { | "user": { "data": { | "meta": { "id": "6", | "included": false "type": "posts" < } } > }, > "comments": { > "data": [ > { > "type": "comments", > "id": "33" > }, > { > "type": "comments", > "id": "34" > } > ] } } } } }, }, { { "id": "12", | "id": "18", "type": "comments", | "type": "posts", "attributes": { "attributes": { "author": "me", | "title": "Some Post", "comment": "nice blog" | "body": "awesome content", > "created_at": "2017-07-01 05:00:00 UTC", > "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "post": { | "user": { "data": { | "meta": { "id": "6", | "included": false "type": "posts" < } } > }, > "comments": { > "data": [ > { > "type": "comments", > "id": "35" > }, > { > "type": "comments", > "id": "36" > } > ] } } } } }, }, { { "id": "7", | "id": "19", "type": "posts", "type": "posts", "attributes": { "attributes": { "title": "Some Post", "title": "Some Post", "body": "awesome content", "body": "awesome content", "created_at": "2017-07-01 05:00:00 UTC", "created_at": "2017-07-01 05:00:00 UTC", "updated_at": "2017-07-01 05:00:00 UTC" "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "user": { "user": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, }, "comments": { "comments": { "data": [ "data": [ { { "id": "13", | "type": "comments", "type": "comments" | "id": "37" }, }, { { "id": "14", | "type": "comments", "type": "comments" | "id": "38" } } ] ] } } } } }, }, { { "id": "13", | "id": "20", "type": "comments", | "type": "posts", "attributes": { "attributes": { "author": "me", | "title": "Some Post", "comment": "nice blog" | "body": "awesome content", > "created_at": "2017-07-01 05:00:00 UTC", > "updated_at": "2017-07-01 05:00:00 UTC" }, }, "relationships": { "relationships": { "post": { | "user": { "data": { | "meta": { "id": "7", | "included": false "type": "posts" < } } > }, > "comments": { > "data": [ > { > "type": "comments", > "id": "39" > }, > { > "type": "comments", > "id": "40" > } > ] } } } } }, }, { { "id": "14", | "id": "1", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "7", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "8", | "id": "2", "type": "posts", | "type": "comments", "attributes": { "attributes": { "title": "Some Post", | "author": "me", "body": "awesome content", | "comment": "nice blog" "created_at": "2017-07-01 05:00:00 UTC", < "updated_at": "2017-07-01 05:00:00 UTC" < }, }, "relationships": { "relationships": { "user": { | "post": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, < "comments": { < "data": [ < { < "id": "15", < "type": "comments" < }, < { < "id": "16", < "type": "comments" < } < ] < } } } } }, }, { { "id": "15", | "id": "3", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "8", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "16", | "id": "4", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "8", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "9", | "id": "5", "type": "posts", | "type": "comments", "attributes": { "attributes": { "title": "Some Post", | "author": "me", "body": "awesome content", | "comment": "nice blog" "created_at": "2017-07-01 05:00:00 UTC", < "updated_at": "2017-07-01 05:00:00 UTC" < }, }, "relationships": { "relationships": { "user": { | "post": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, < "comments": { < "data": [ < { < "id": "17", < "type": "comments" < }, < { < "id": "18", < "type": "comments" < } < ] < } } } } }, }, { { "id": "17", | "id": "6", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "9", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "18", | "id": "7", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "9", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "10", | "id": "8", "type": "posts", | "type": "comments", "attributes": { "attributes": { "title": "Some Post", | "author": "me", "body": "awesome content", | "comment": "nice blog" "created_at": "2017-07-01 05:00:00 UTC", < "updated_at": "2017-07-01 05:00:00 UTC" < }, }, "relationships": { "relationships": { "user": { | "post": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, < "comments": { < "data": [ < { < "id": "19", < "type": "comments" < }, < { < "id": "20", < "type": "comments" < } < ] < } } } } }, }, { { "id": "19", | "id": "9", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "10", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "20", | "id": "10", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "10", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "11", "id": "11", "type": "posts", | "type": "comments", "attributes": { "attributes": { "title": "Some Post", | "author": "me", "body": "awesome content", | "comment": "nice blog" "created_at": "2017-07-01 05:00:00 UTC", < "updated_at": "2017-07-01 05:00:00 UTC" < }, }, "relationships": { "relationships": { "user": { | "post": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, < "comments": { < "data": [ < { < "id": "21", < "type": "comments" < }, < { < "id": "22", < "type": "comments" < } < ] < } } } } }, }, { { "id": "21", | "id": "12", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "11", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "22", | "id": "13", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "11", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "12", | "id": "14", "type": "posts", | "type": "comments", "attributes": { "attributes": { "title": "Some Post", | "author": "me", "body": "awesome content", | "comment": "nice blog" "created_at": "2017-07-01 05:00:00 UTC", < "updated_at": "2017-07-01 05:00:00 UTC" < }, }, "relationships": { "relationships": { "user": { | "post": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, < "comments": { < "data": [ < { < "id": "23", < "type": "comments" < }, < { < "id": "24", < "type": "comments" < } < ] < } } } } }, }, { { "id": "23", | "id": "15", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "12", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "24", | "id": "16", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "12", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "13", | "id": "17", "type": "posts", | "type": "comments", "attributes": { "attributes": { "title": "Some Post", | "author": "me", "body": "awesome content", | "comment": "nice blog" "created_at": "2017-07-01 05:00:00 UTC", < "updated_at": "2017-07-01 05:00:00 UTC" < }, }, "relationships": { "relationships": { "user": { | "post": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, < "comments": { < "data": [ < { < "id": "25", < "type": "comments" < }, < { < "id": "26", < "type": "comments" < } < ] < } } } } }, }, { { "id": "25", | "id": "18", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "13", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "26", | "id": "19", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "13", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "14", | "id": "20", "type": "posts", | "type": "comments", "attributes": { "attributes": { "title": "Some Post", | "author": "me", "body": "awesome content", | "comment": "nice blog" "created_at": "2017-07-01 05:00:00 UTC", < "updated_at": "2017-07-01 05:00:00 UTC" < }, }, "relationships": { "relationships": { "user": { | "post": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, < "comments": { < "data": [ < { < "id": "27", < "type": "comments" < }, < { < "id": "28", < "type": "comments" < } < ] < } } } } }, }, { { "id": "27", | "id": "21", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "14", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "28", | "id": "22", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "14", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "15", | "id": "23", "type": "posts", | "type": "comments", "attributes": { "attributes": { "title": "Some Post", | "author": "me", "body": "awesome content", | "comment": "nice blog" "created_at": "2017-07-01 05:00:00 UTC", < "updated_at": "2017-07-01 05:00:00 UTC" < }, }, "relationships": { "relationships": { "user": { | "post": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, < "comments": { < "data": [ < { < "id": "29", < "type": "comments" < }, < { < "id": "30", < "type": "comments" < } < ] < } } } } }, }, { { "id": "29", | "id": "24", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "15", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "30", | "id": "25", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "15", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "16", | "id": "26", "type": "posts", | "type": "comments", "attributes": { "attributes": { "title": "Some Post", | "author": "me", "body": "awesome content", | "comment": "nice blog" "created_at": "2017-07-01 05:00:00 UTC", < "updated_at": "2017-07-01 05:00:00 UTC" < }, }, "relationships": { "relationships": { "user": { | "post": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, < "comments": { < "data": [ < { < "id": "31", < "type": "comments" < }, < { < "id": "32", < "type": "comments" < } < ] < } } } } }, }, { { "id": "31", | "id": "27", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "16", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "32", | "id": "28", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "16", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "17", | "id": "29", "type": "posts", | "type": "comments", "attributes": { "attributes": { "title": "Some Post", | "author": "me", "body": "awesome content", | "comment": "nice blog" "created_at": "2017-07-01 05:00:00 UTC", < "updated_at": "2017-07-01 05:00:00 UTC" < }, }, "relationships": { "relationships": { "user": { | "post": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, < "comments": { < "data": [ < { < "id": "33", < "type": "comments" < }, < { < "id": "34", < "type": "comments" < } < ] < } } } } }, }, { { "id": "33", | "id": "30", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "17", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "34", | "id": "31", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "17", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "18", | "id": "32", "type": "posts", | "type": "comments", "attributes": { "attributes": { "title": "Some Post", | "author": "me", "body": "awesome content", | "comment": "nice blog" "created_at": "2017-07-01 05:00:00 UTC", < "updated_at": "2017-07-01 05:00:00 UTC" < }, }, "relationships": { "relationships": { "user": { | "post": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, < "comments": { < "data": [ < { < "id": "35", < "type": "comments" < }, < { < "id": "36", < "type": "comments" < } < ] < } } } } }, }, { { "id": "35", | "id": "33", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "18", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "36", | "id": "34", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "18", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "19", | "id": "35", "type": "posts", | "type": "comments", "attributes": { "attributes": { "title": "Some Post", | "author": "me", "body": "awesome content", | "comment": "nice blog" "created_at": "2017-07-01 05:00:00 UTC", < "updated_at": "2017-07-01 05:00:00 UTC" < }, }, "relationships": { "relationships": { "user": { | "post": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, < "comments": { < "data": [ < { < "id": "37", < "type": "comments" < }, < { < "id": "38", < "type": "comments" < } < ] < } } } } }, }, { { "id": "37", | "id": "36", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "19", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "38", | "id": "37", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "19", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "20", | "id": "38", "type": "posts", | "type": "comments", "attributes": { "attributes": { "title": "Some Post", | "author": "me", "body": "awesome content", | "comment": "nice blog" "created_at": "2017-07-01 05:00:00 UTC", < "updated_at": "2017-07-01 05:00:00 UTC" < }, }, "relationships": { "relationships": { "user": { | "post": { "data": { | "meta": { "id": "1", | "included": false "type": "users" < } } }, < "comments": { < "data": [ < { < "id": "39", < "type": "comments" < }, < { < "id": "40", < "type": "comments" < } < ] < } } } } }, }, { { "id": "39", "id": "39", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "20", | "included": false "type": "posts" < } } } } } } }, }, { { "id": "40", "id": "40", "type": "comments", "type": "comments", "attributes": { "attributes": { "author": "me", "author": "me", "comment": "nice blog" "comment": "nice blog" }, }, "relationships": { "relationships": { "post": { "post": { "data": { | "meta": { "id": "20", | "included": false "type": "posts" < } } } } } } } } ] ] } } ``` --- .../serialization_libraries/benchmark.rb | 2 + .../support/bench_helper.rb | 33 + .../support/json_document-ams.json | 1341 +++++++++++++++++ .../support/json_document-jsonapi_rb.json | 1281 ++++++++++++++++ 4 files changed, 2657 insertions(+) create mode 100644 benchmarks/serialization_libraries/support/json_document-ams.json create mode 100644 benchmarks/serialization_libraries/support/json_document-jsonapi_rb.json diff --git a/benchmarks/serialization_libraries/benchmark.rb b/benchmarks/serialization_libraries/benchmark.rb index 93dbef17..6793a17a 100644 --- a/benchmarks/serialization_libraries/benchmark.rb +++ b/benchmarks/serialization_libraries/benchmark.rb @@ -24,6 +24,8 @@ GC.disable %i[ips memory].each do |bench| BenchHelper.clear_data BenchHelper.seed_data + BenchHelper.validate_render(:ams) + BenchHelper.validate_render(:jsonapi_rb) Benchmark.send(bench) do |x| x.config(time: 10, warmup: 5, stats: :bootstrap, confidence: 95) if x.respond_to?(:config) diff --git a/benchmarks/serialization_libraries/support/bench_helper.rb b/benchmarks/serialization_libraries/support/bench_helper.rb index a512303b..bedebd3f 100644 --- a/benchmarks/serialization_libraries/support/bench_helper.rb +++ b/benchmarks/serialization_libraries/support/bench_helper.rb @@ -24,6 +24,39 @@ module BenchHelper end end + def validate_render(render_gem) + expected_json_file = File.join("support", "json_document-#{render_gem}.json") + json_document = test_render(render_gem) + assert_equal_json("[#{render_gem}] :test_render", expected_json_file, json_document) + json_document = test_manual_eagerload(render_gem) + assert_equal_json("[#{render_gem}] :test_manual_eagerload", expected_json_file, json_document) + end + + require "fileutils" + def assert_equal_json(description, expected_json_file, actual_json_document) + # 1. in tmp/ + temp_dir = "tmp" + FileUtils.mkdir_p(temp_dir) + # 2. write pretty actual json doc + actual_json_file = File.join(temp_dir, "actual--#{File.basename(expected_json_file)}") + actual_json_document = JSON.pretty_generate(actual_json_document) + File.write(actual_json_file, actual_json_document) + # 3. if expected json doc missing, copy actual to expected + unless File.exist?(expected_json_file) + FileUtils.cp(actual_json_file, expected_json_file) + end + # 4. Check for differences + cmd = "diff --suppress-common-lines --side-by-side #{expected_json_file} #{actual_json_file}" + diff = `#{cmd}`.chomp + # 5. If none, 'true', they are equal + # else make a full diff for later review + return true if diff.empty? + cmd = "diff --side-by-side #{expected_json_file} #{actual_json_file} > #{File.join(temp_dir, "actual--#{File.basename(expected_json_file)}")}.diff" + system(cmd) + # 6. abort run, print brief diff + abort "#{description}. Invalid JSON document.\nDiff:\n#{diff}}" + end + def test_render(render_gem) render_data( User.first, diff --git a/benchmarks/serialization_libraries/support/json_document-ams.json b/benchmarks/serialization_libraries/support/json_document-ams.json new file mode 100644 index 00000000..7bcdbc84 --- /dev/null +++ b/benchmarks/serialization_libraries/support/json_document-ams.json @@ -0,0 +1,1341 @@ +{ + "data": { + "id": "1", + "type": "users", + "attributes": { + "first_name": "Diana", + "last_name": "Prince", + "birthday": "2017-07-01 05:00:00 UTC", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "posts": { + "data": [ + { + "id": "1", + "type": "posts" + }, + { + "id": "2", + "type": "posts" + }, + { + "id": "3", + "type": "posts" + }, + { + "id": "4", + "type": "posts" + }, + { + "id": "5", + "type": "posts" + }, + { + "id": "6", + "type": "posts" + }, + { + "id": "7", + "type": "posts" + }, + { + "id": "8", + "type": "posts" + }, + { + "id": "9", + "type": "posts" + }, + { + "id": "10", + "type": "posts" + }, + { + "id": "11", + "type": "posts" + }, + { + "id": "12", + "type": "posts" + }, + { + "id": "13", + "type": "posts" + }, + { + "id": "14", + "type": "posts" + }, + { + "id": "15", + "type": "posts" + }, + { + "id": "16", + "type": "posts" + }, + { + "id": "17", + "type": "posts" + }, + { + "id": "18", + "type": "posts" + }, + { + "id": "19", + "type": "posts" + }, + { + "id": "20", + "type": "posts" + } + ] + } + } + }, + "included": [ + { + "id": "1", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "1", + "type": "comments" + }, + { + "id": "2", + "type": "comments" + } + ] + } + } + }, + { + "id": "1", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "1", + "type": "posts" + } + } + } + }, + { + "id": "2", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "1", + "type": "posts" + } + } + } + }, + { + "id": "2", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "3", + "type": "comments" + }, + { + "id": "4", + "type": "comments" + } + ] + } + } + }, + { + "id": "3", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "2", + "type": "posts" + } + } + } + }, + { + "id": "4", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "2", + "type": "posts" + } + } + } + }, + { + "id": "3", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "5", + "type": "comments" + }, + { + "id": "6", + "type": "comments" + } + ] + } + } + }, + { + "id": "5", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "3", + "type": "posts" + } + } + } + }, + { + "id": "6", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "3", + "type": "posts" + } + } + } + }, + { + "id": "4", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "7", + "type": "comments" + }, + { + "id": "8", + "type": "comments" + } + ] + } + } + }, + { + "id": "7", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "4", + "type": "posts" + } + } + } + }, + { + "id": "8", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "4", + "type": "posts" + } + } + } + }, + { + "id": "5", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "9", + "type": "comments" + }, + { + "id": "10", + "type": "comments" + } + ] + } + } + }, + { + "id": "9", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "5", + "type": "posts" + } + } + } + }, + { + "id": "10", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "5", + "type": "posts" + } + } + } + }, + { + "id": "6", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "11", + "type": "comments" + }, + { + "id": "12", + "type": "comments" + } + ] + } + } + }, + { + "id": "11", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "6", + "type": "posts" + } + } + } + }, + { + "id": "12", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "6", + "type": "posts" + } + } + } + }, + { + "id": "7", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "13", + "type": "comments" + }, + { + "id": "14", + "type": "comments" + } + ] + } + } + }, + { + "id": "13", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "7", + "type": "posts" + } + } + } + }, + { + "id": "14", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "7", + "type": "posts" + } + } + } + }, + { + "id": "8", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "15", + "type": "comments" + }, + { + "id": "16", + "type": "comments" + } + ] + } + } + }, + { + "id": "15", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "8", + "type": "posts" + } + } + } + }, + { + "id": "16", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "8", + "type": "posts" + } + } + } + }, + { + "id": "9", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "17", + "type": "comments" + }, + { + "id": "18", + "type": "comments" + } + ] + } + } + }, + { + "id": "17", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "9", + "type": "posts" + } + } + } + }, + { + "id": "18", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "9", + "type": "posts" + } + } + } + }, + { + "id": "10", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "19", + "type": "comments" + }, + { + "id": "20", + "type": "comments" + } + ] + } + } + }, + { + "id": "19", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "10", + "type": "posts" + } + } + } + }, + { + "id": "20", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "10", + "type": "posts" + } + } + } + }, + { + "id": "11", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "21", + "type": "comments" + }, + { + "id": "22", + "type": "comments" + } + ] + } + } + }, + { + "id": "21", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "11", + "type": "posts" + } + } + } + }, + { + "id": "22", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "11", + "type": "posts" + } + } + } + }, + { + "id": "12", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "23", + "type": "comments" + }, + { + "id": "24", + "type": "comments" + } + ] + } + } + }, + { + "id": "23", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "12", + "type": "posts" + } + } + } + }, + { + "id": "24", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "12", + "type": "posts" + } + } + } + }, + { + "id": "13", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "25", + "type": "comments" + }, + { + "id": "26", + "type": "comments" + } + ] + } + } + }, + { + "id": "25", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "13", + "type": "posts" + } + } + } + }, + { + "id": "26", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "13", + "type": "posts" + } + } + } + }, + { + "id": "14", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "27", + "type": "comments" + }, + { + "id": "28", + "type": "comments" + } + ] + } + } + }, + { + "id": "27", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "14", + "type": "posts" + } + } + } + }, + { + "id": "28", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "14", + "type": "posts" + } + } + } + }, + { + "id": "15", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "29", + "type": "comments" + }, + { + "id": "30", + "type": "comments" + } + ] + } + } + }, + { + "id": "29", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "15", + "type": "posts" + } + } + } + }, + { + "id": "30", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "15", + "type": "posts" + } + } + } + }, + { + "id": "16", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "31", + "type": "comments" + }, + { + "id": "32", + "type": "comments" + } + ] + } + } + }, + { + "id": "31", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "16", + "type": "posts" + } + } + } + }, + { + "id": "32", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "16", + "type": "posts" + } + } + } + }, + { + "id": "17", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "33", + "type": "comments" + }, + { + "id": "34", + "type": "comments" + } + ] + } + } + }, + { + "id": "33", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "17", + "type": "posts" + } + } + } + }, + { + "id": "34", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "17", + "type": "posts" + } + } + } + }, + { + "id": "18", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "35", + "type": "comments" + }, + { + "id": "36", + "type": "comments" + } + ] + } + } + }, + { + "id": "35", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "18", + "type": "posts" + } + } + } + }, + { + "id": "36", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "18", + "type": "posts" + } + } + } + }, + { + "id": "19", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "37", + "type": "comments" + }, + { + "id": "38", + "type": "comments" + } + ] + } + } + }, + { + "id": "37", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "19", + "type": "posts" + } + } + } + }, + { + "id": "38", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "19", + "type": "posts" + } + } + } + }, + { + "id": "20", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "data": { + "id": "1", + "type": "users" + } + }, + "comments": { + "data": [ + { + "id": "39", + "type": "comments" + }, + { + "id": "40", + "type": "comments" + } + ] + } + } + }, + { + "id": "39", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "20", + "type": "posts" + } + } + } + }, + { + "id": "40", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "data": { + "id": "20", + "type": "posts" + } + } + } + } + ] +} \ No newline at end of file diff --git a/benchmarks/serialization_libraries/support/json_document-jsonapi_rb.json b/benchmarks/serialization_libraries/support/json_document-jsonapi_rb.json new file mode 100644 index 00000000..525a05a3 --- /dev/null +++ b/benchmarks/serialization_libraries/support/json_document-jsonapi_rb.json @@ -0,0 +1,1281 @@ +{ + "data": { + "id": "1", + "type": "users", + "attributes": { + "first_name": "Diana", + "last_name": "Prince", + "birthday": "2017-07-01 05:00:00 UTC", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "posts": { + "data": [ + { + "type": "posts", + "id": "1" + }, + { + "type": "posts", + "id": "2" + }, + { + "type": "posts", + "id": "3" + }, + { + "type": "posts", + "id": "4" + }, + { + "type": "posts", + "id": "5" + }, + { + "type": "posts", + "id": "6" + }, + { + "type": "posts", + "id": "7" + }, + { + "type": "posts", + "id": "8" + }, + { + "type": "posts", + "id": "9" + }, + { + "type": "posts", + "id": "10" + }, + { + "type": "posts", + "id": "11" + }, + { + "type": "posts", + "id": "12" + }, + { + "type": "posts", + "id": "13" + }, + { + "type": "posts", + "id": "14" + }, + { + "type": "posts", + "id": "15" + }, + { + "type": "posts", + "id": "16" + }, + { + "type": "posts", + "id": "17" + }, + { + "type": "posts", + "id": "18" + }, + { + "type": "posts", + "id": "19" + }, + { + "type": "posts", + "id": "20" + } + ] + } + } + }, + "included": [ + { + "id": "1", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "1" + }, + { + "type": "comments", + "id": "2" + } + ] + } + } + }, + { + "id": "2", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "3" + }, + { + "type": "comments", + "id": "4" + } + ] + } + } + }, + { + "id": "3", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "5" + }, + { + "type": "comments", + "id": "6" + } + ] + } + } + }, + { + "id": "4", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "7" + }, + { + "type": "comments", + "id": "8" + } + ] + } + } + }, + { + "id": "5", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "9" + }, + { + "type": "comments", + "id": "10" + } + ] + } + } + }, + { + "id": "6", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "11" + }, + { + "type": "comments", + "id": "12" + } + ] + } + } + }, + { + "id": "7", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "13" + }, + { + "type": "comments", + "id": "14" + } + ] + } + } + }, + { + "id": "8", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "15" + }, + { + "type": "comments", + "id": "16" + } + ] + } + } + }, + { + "id": "9", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "17" + }, + { + "type": "comments", + "id": "18" + } + ] + } + } + }, + { + "id": "10", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "19" + }, + { + "type": "comments", + "id": "20" + } + ] + } + } + }, + { + "id": "11", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "21" + }, + { + "type": "comments", + "id": "22" + } + ] + } + } + }, + { + "id": "12", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "23" + }, + { + "type": "comments", + "id": "24" + } + ] + } + } + }, + { + "id": "13", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "25" + }, + { + "type": "comments", + "id": "26" + } + ] + } + } + }, + { + "id": "14", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "27" + }, + { + "type": "comments", + "id": "28" + } + ] + } + } + }, + { + "id": "15", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "29" + }, + { + "type": "comments", + "id": "30" + } + ] + } + } + }, + { + "id": "16", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "31" + }, + { + "type": "comments", + "id": "32" + } + ] + } + } + }, + { + "id": "17", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "33" + }, + { + "type": "comments", + "id": "34" + } + ] + } + } + }, + { + "id": "18", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "35" + }, + { + "type": "comments", + "id": "36" + } + ] + } + } + }, + { + "id": "19", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "37" + }, + { + "type": "comments", + "id": "38" + } + ] + } + } + }, + { + "id": "20", + "type": "posts", + "attributes": { + "title": "Some Post", + "body": "awesome content", + "created_at": "2017-07-01 05:00:00 UTC", + "updated_at": "2017-07-01 05:00:00 UTC" + }, + "relationships": { + "user": { + "meta": { + "included": false + } + }, + "comments": { + "data": [ + { + "type": "comments", + "id": "39" + }, + { + "type": "comments", + "id": "40" + } + ] + } + } + }, + { + "id": "1", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "2", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "3", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "4", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "5", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "6", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "7", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "8", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "9", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "10", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "11", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "12", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "13", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "14", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "15", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "16", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "17", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "18", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "19", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "20", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "21", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "22", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "23", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "24", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "25", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "26", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "27", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "28", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "29", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "30", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "31", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "32", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "33", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "34", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "35", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "36", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "37", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "38", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "39", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + }, + { + "id": "40", + "type": "comments", + "attributes": { + "author": "me", + "comment": "nice blog" + }, + "relationships": { + "post": { + "meta": { + "included": false + } + } + } + } + ] +} \ No newline at end of file