Get started with json2 CDN
Unlicense licensed
JSON2 is a lightweight library for parsing and stringifying JSON data.
Tags:- json
- popular
Stable version
Copied!
How to start using json2 CDN
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.cdnhub.io/json2/20160511/json2.min.js"></script>
<title>Get started with json2 CDN - cdnhub.io</title>
</head>
<body>
<button id="parse">Parse JSON</button>
<button id="stringify">Stringify JSON</button>
<script>
const parseBtn = document.getElementById('parse');
const stringifyBtn = document.getElementById('stringify');
parseBtn.addEventListener('click', () => {
const jsonString = '{"name": "John Doe", "age": 30}';
const parsedJson = JSON.parse(jsonString);
console.log(parsedJson); // { name: 'John Doe', age: 30 }
});
stringifyBtn.addEventListener('click', () => {
const jsonObject = { name: 'Jane Doe', age: 28 };
const jsonStringified = JSON.stringify(jsonObject);
console.log(jsonStringified); // "{"name":"Jane Doe","age":28}"
});
</script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!