You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-13Lines changed: 19 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ AMS does this through two components: **serializers** and **adapters**.
8
8
Serializers describe _which_ attributes and relationships should be serialized.
9
9
Adapters describe _how_ attributes and relationships should be serialized.
10
10
11
-
By default AMS will use the **Json Adapter**. But we strongly advise you to use JsonApi Adapter that follows 1.0 of the format specified in [jsonapi.org/format](http://jsonapi.org/format).
11
+
By default AMS will use the **Flatten Json Adapter**. But we strongly advise you to use **JsonApi Adapter** that follows 1.0 of the format specified in [jsonapi.org/format](http://jsonapi.org/format).
12
12
Check how to change the adapter in the sections bellow.
`meta` will only be included in your response if there's a root. For instance,
134
-
it won't be included in array responses.
135
-
136
-
### Root key
137
-
138
-
If you want to define a custom root for your response, specify it in the `render`
139
-
call:
140
-
141
-
```ruby
142
-
render json:@post, root:"articles"
143
-
```
139
+
`meta` will only be included in your response if you are using an Adapter that supports `root`, as JsonAPI and Json adapters, the default adapter (FlattenJson) doesn't have `root`.
144
140
145
141
### Overriding association methods
146
142
@@ -176,9 +172,19 @@ end
176
172
177
173
### Built in Adapters
178
174
175
+
#### FlattenJSON
176
+
177
+
It's the default adapter, it generates a json response without a root key.
178
+
Doesn't follow any specifc convention.
179
+
180
+
#### JSON
181
+
182
+
It also generates a json response but always with a root key. The root key **can't be overridden**, and will be automatically defined accordingly with the objects being serialized.
183
+
Doesn't follow any specifc convention.
184
+
179
185
#### JSONAPI
180
186
181
-
This adapter follows RC4 of the format specified in
187
+
This adapter follows 1.0 of the format specified in
182
188
[jsonapi.org/format](http://jsonapi.org/format). It will include the associated
183
189
resources in the `"included"` member when the resource names are included in the
0 commit comments