Skip to content

Commit

Permalink
Added a new example
Browse files Browse the repository at this point in the history
  • Loading branch information
František Hába committed Mar 5, 2012
1 parent ac6b189 commit f425166
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,27 @@ data = JSON.stringify(data);
pinch(data, 'users[0].name', 'Juan');
```

Well, in this case Pinch is overkill, but... Pinch is very useful for replacing multiple keys, e.g. converting some values to a number.

```javascript
var data = {
user: {
id: '123'
},
request: {
id: '456'
},
book: {
id: '789'
}
};

// Converts all ids to a number
pinch(data, /id/, function(path, key, value) {
return parseInt(value);
});
```

<a name="Contents"></a>
### Contents

Expand Down

0 comments on commit f425166

Please sign in to comment.