README.md in strong_json-0.2.0 vs README.md in strong_json-0.3.0
- old
+ new
@@ -24,15 +24,24 @@
## Usage
```ruby
s = StrongJSON.new do
let :item, object(id: prohibited, name: string, count: numeric)
- let :custoemr, object(name: string, address: string, phone: string, email: optional(string))
+ let :customer, object(name: string, address: string, phone: string, email: optional(string))
let :order, object(customer: customer, items: array(item))
end
json = s.order.coerce(JSON.parse(input), symbolize_names: true)
s.order =~ JSON.parse(input, symbolize_names: true)
+
+case JSON.parse(input2, symbolize_names: true)
+when s.item
+ # input2 is an item
+when s.customer
+ # input2 is a customer
+else
+ # input2 is something else
+end
```
If the input JSON data conforms to `order`'s structure, the `json` will be that value.
If the input JSON contains attributes which is not white-listed in the definition, it will raise an exception.