Travis build: 733 [ci skip]

This commit is contained in:
Travis CI
2017-12-31 13:18:31 +00:00
parent 4774d42eb7
commit 92fbafdc5d
3 changed files with 7 additions and 5 deletions

View File

@ -4246,13 +4246,13 @@ isSymbol(Symbol('x')); // true
Checks if the provided argument is a valid JSON.
Use `JSON.parse()` and a `try... catch` block to check if the provided argument is a valid JSON and non-null.
Use `JSON.parse()` and a `try... catch` block to check if the provided argument is a valid JSON.
```js
const isValidJSON = obj => {
try {
JSON.parse(obj);
return !!obj;
return true;
} catch (e) {
return false;
}
@ -4265,6 +4265,7 @@ const isValidJSON = obj => {
```js
isValidJSON('{"name":"Adam","age":20}'); // true
isValidJSON('{"name":"Adam",age:"20"}'); // false
isValidJSON(null); // true
```
</details>