Skip to content

Commit 96cf587

Browse files
committed
Add formatted JSON result to README example
This should help visualise what the outcome should look like.
1 parent 807a2ea commit 96cf587

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,33 @@ gem "transmutation"
4848
UserSerializer.new(user).to_json # => "{\"id\":1,\"name\":\"John Doe\",\"has_space_in_name\":true,\"email\":\"john@example.com\",\"organization\":{\"id\":1,\"name\":\"Example Inc.\"},\"posts\":[{\"id\":1,\"title\":\"My first post\",\"body\":\"Sample body\"},{\"id\":3,\"title\":\"This looks promising\",\"body\":\"More content\"}]}"
4949
```
5050

51+
Formatted JSON output:
52+
53+
```json
54+
{
55+
"id": 1,
56+
"name": "John Doe",
57+
"has_space_in_name": true,
58+
"email": "john@example.com",
59+
"organization": {
60+
"id": 1,
61+
"name": "Example Inc."
62+
},
63+
"posts": [
64+
{
65+
"id": 1,
66+
"title": "My first post",
67+
"body": "Sample body"
68+
},
69+
{
70+
"id": 3,
71+
"title": "This looks promising",
72+
"body": "More content"
73+
}
74+
]
75+
}
76+
```
77+
5178
As long as your object responds to the attributes defined in the serializer, it can be serialized.
5279

5380
<details>

0 commit comments

Comments
 (0)