Deno.js Tutorial to Validate JSON Objects Schema Using isJSON Module Using TypeScript Full Project For Beginners





Check if the string is a valid JSON structure


import the module in your deno app

import { isJSON } from ''

or from packages

import { isJSON } from ''


console.log(isJSON('{"username": "moncefplastin07"}'))                 // true
console.log(isJSON('{"favoriteColors": ["red", "green", "black"]}'))   // true
const users = '[{"username": "moncefplastin07", "favoriteColors": ["red", "green", "black"]},{"username": "moncefplastin08", "favoriteColors": ["yellow", "green", "blue"]}]'
console.log(isJSON(users))                                             // true

console.log(isJSON("{'username': 'moncefplastin07'}"))                 // false
console.log(isJSON(12))                                                // false
console.log(isJSON({isAdmin: true}))

Leave a Reply