Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
antonholmquist committed Dec 2, 2014
1 parent 1b78d2c commit ef2031f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,25 @@ root.Get("friends").IsNull()

### Loop through array

Looping through an array is easy and will never return an exeption. `Array()` returns an empty array if the value at that keypath is null or something else than an array.
Looping through an array is easy and will never return an exeption. `Array()` returns an empty slice if the value at that keypath is null (or something else than an array).

```
for _, friend := person.Get("friends").Array() {
for _, friend := range person.Get("friends").Array() {
name := friend.Get("name").String()
age := friend.Get("age").Number()
}
```

### Loop through object

Looping through an object is easy and will never return an exeption. `Object()` returns an empty map if the value at that keypath is null (or something else than an object).

```
for key, value := person.Get("person").Object() {
...
}
```


## Sample Project

Expand Down

0 comments on commit ef2031f

Please sign in to comment.