Last Updated: June 01, 2017
·
1.553K
· Codi

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

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
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