Get started with json5 CDN
MIT licensed
JSON5 is a library that extends JSON with non-standard JSON-like syntax, including support for comments and nullable values.
Tags:- json
Stable version
Copied!
How to start using json5 CDN
<!DOCTYPE html>
<html>
<head>
<title>Get started with json5 CDN - cdnhub.io</title>
</head>
<body>
<script src="https://cdn.cdnhub.io/json5/2.2.3/index.min.js"></script>
<script>
// Parse JSON5 string
const json5String = `
{
"name": "John Doe",
"age": 30,
"hobbies": ["reading", "swimming"],
"address": {
"street": "123 Main St",
"city": "Anytown",
"state": "CA",
"zip": 12345
},
"skills": [
{
"name": "JavaScript",
"level": "advanced"
},
{
"name": "Python",
"level": "intermediate"
}
],
"isMarried": true,
"pets": null
}
`;
const json5Object = JSON5.parse(json5String);
console.log(json5Object); // Logs the parsed JSON5 object
// Stringify JSON5 object
const json5Stringified = JSON5.stringify(json5Object, null, 2);
console.log(json5Stringified); // Logs the JSON5 stringified object with 2 spaces indentation
</script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!