summaryrefslogtreecommitdiffhomepage
path: root/README.md
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-09-26 22:07:45 +0200
committerJo-Philipp Wich <jo@mein.io>2020-09-26 22:07:45 +0200
commit76cd3c66f2f34e10749cabb7d489210c48d03342 (patch)
tree08303dd0cdf92210d4c0dff90e66640ab082c830 /README.md
parent087b6c77a1e2cbb014bb19a4bed78a04336d51dc (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.md10
1 files changed, 10 insertions, 0 deletions
diff --git a/README.md b/README.md
index 07b384f..d3bf8da 100644
--- a/README.md
+++ b/README.md
@@ -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
+```