You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17-2Lines changed: 17 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -35,9 +35,24 @@ Example:
35
35
"full": "{{ first }} {{ last }}"
36
36
}
37
37
```
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.
39
39
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' });
0 commit comments