Example 1 — Match six JSON types
A helper that mirrors common type checks.
function jsonType(value) {
if (value === null) return "null";
if (Array.isArray(value)) return "array";
return typeof value; // string, number, boolean, object
}
const samples = ["Ada", 36, true, null, { a: 1 }, [1, 2]];
samples.forEach(function (v) {
console.log(JSON.stringify(v) + " → " + jsonType(v));
}); How It Works
- JSON has six value kinds in the data model.
- Schema
integeris an extra check on numbers. - Use
typeto declare which kind you expect.

