Skip to content

Commit a4fb5fb

Browse files
committed
update readme
1 parent 11c2af7 commit a4fb5fb

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,24 @@ Example:
3535
"full": "{{ first }} {{ last }}"
3636
}
3737
```
38-
If your JSON is a first level array you can use paths like this `{{ [0].first }}` or if you think it's more readible, `{{ @self[0].first }}` works as well.
38+
If your JSON is a first level array you can use paths like this `{{ [0].first }}` or if you think it's more readable, `{{ @self[0].first }}` works as well.
3939

40-
**Note:** Due to the nature of template tags, everything that passes through them will be convered to string, whereas `@self` notation can replace itself with whatever it is referencing.
40+
**Note:** Due to the nature of template tags, everything that passes through them will be converted to string, whereas `@self` notation can replace itself with whatever it is referencing.
41+
42+
## Resolve function
43+
Additionally, you can use the reference resolver directly. You might be parsing your JSON files with your own system i.e. streaming and you might only want to have the reference resolver. Here is an example
44+
45+
```javascript
46+
var resolve = require('jsonplus').resolve
47+
48+
// This will resolve all reference strings on the given object
49+
var object = resolve(AlreadyParsedJSON);
50+
51+
// resolve has a second argument, which provides the context for references
52+
var object = resolve({ full: '{{ first }} {{ last }}' }, { first: 'john', last: 'doe' });
53+
54+
console.log(object) // { full: 'john doe' }
55+
```
4156

4257
## A complex example
4358
```javascript

0 commit comments

Comments
 (0)