diff options
author | Jo-Philipp Wich <jo@mein.io> | 2020-09-26 22:07:45 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2020-09-26 22:07:45 +0200 |
commit | 76cd3c66f2f34e10749cabb7d489210c48d03342 (patch) | |
tree | 08303dd0cdf92210d4c0dff90e66640ab082c830 /README.md | |
parent | 087b6c77a1e2cbb014bb19a4bed78a04336d51dc (diff) |
lib: add json() function
The json function allows parsing JSON strings into structured data.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -945,3 +945,13 @@ replace("barfoobaz", /(.)(.)(.)/g, function(m, c1, c2, c3) { return c3 + c2 + c1; }) // raboofzab ``` + +#### 6.49. `json(str)` + +Parse the given string as JSON and return the resulting value. Throws an +exception on parse errors, trailing garbage or premature EOF. + +```javascript +json('{"a":true, "b":123}') // { "a": true, "b": 123 } +json('[1,2,') // Throws exception +``` |