Skip to content

Commit 610bd00

Browse files
committed
adding documentation about key transforms
1 parent 7daeb82 commit 610bd00

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Fast JSON API serialized 250 records in 3.01 ms
2525
* [Serializer Definition](#serializer-definition)
2626
* [Object Serialization](#object-serialization)
2727
* [Compound Document](#compound-document)
28+
* [Key Transforms](#key-transforms)
2829
* [Collection Serialization](#collection-serialization)
2930
* [Caching](#caching)
3031
* [Contributing](#contributing)
@@ -134,6 +135,26 @@ json_string = MovieSerializer.new(movie).serialized_json
134135
}
135136

136137
```
138+
139+
### Key Transforms
140+
By default fast_jsonapi underscores the key names. It supports the same key transforms that are supported by AMS. Here is the syntax of specifying a key transform
141+
142+
```ruby
143+
class MovieSerializer
144+
include FastJsonapi::ObjectSerializer
145+
# Available options :camel, :camel_lower, :dash, :underscore(default)
146+
set_key_transform :camel
147+
end
148+
```
149+
Here are examples of how these options transform the keys
150+
151+
```ruby
152+
set_key_transform :camel # "some_key" => "SomeKey"
153+
set_key_transform :camel_lower # "some_key" => "someKey"
154+
set_key_transform :dash # "some_key" => "some-key"
155+
set_key_transform :underscore # "some_key" => "some_key"
156+
```
157+
137158
### Compound Document
138159

139160
Support for top-level included member through ` options[:include] `.

0 commit comments

Comments
 (0)