Validate or check a json string in Javascript
You can use this json validator Javascript component to validate a json string, returning the exception if not (see tests).
Example:
const vaildateJson = require('bit/global/json-validator');
vaildateJson(jsonStr).catch(err => console.log(err))
Test Summary
validate json string validate proper json str - Pass
validate json string when sending number should get exception - Pass
validate json string when sending broken json should get exception - Pass
Written by Codi
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#