<!
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JSON and Crypto Example</title>
<style>
body { font-family: Arial, sans-serif; margin: 20px; }
h2 { color: #333; }
</style>
</head>
<body>
<h2>JSON and Crypto Operations</h2>
<!-- JSON to Object -->
<div>
<h3>Convert JSON to JavaScript Object:</h3>
<p id="jsonToObj"></p>
</div>
<!-- JSON Date Conversion -->
<div>
<h3>Convert JSON Date:</h3>
<p id="jsonDate"></p>
</div>
<!-- JSON to CSV and CSV to JSON -->
<div>
<h3>JSON to CSV:</h3>
<p id="jsonToCsv"></p>
</div>
<div>
<h3>CSV to JSON:</h3>
<p id="csvToJson"></p>
</div>
<!-- Hashing a String -->
<div>
<h3>Create Hash from String:</h3>
<p id="hashOutput"></p>
</div>
<script>
// Sample JSON string
const jsonString = '{"name": "John", "age": 30, "dateOfBirth": "1994-01-01"}';
// a) Convert JSON text to JavaScript Object
const jsonObject = [Link](jsonString);
[Link]("jsonToObj").innerText = [Link](jsonObject);
// b) Convert JSON results into a date
const date = new Date([Link]);
[Link]("jsonDate").innerText = [Link]();
// c) Converting From JSON To CSV
function jsonToCsv(json) {
const items = typeof json ! == 'object' ? [Link](json) : json;
const header = [Link](items);
const csv = [Link](',') + '\n' + [Link](field =>
items[field]).join(',');
return csv;
}
const csvOutput = jsonToCsv(jsonObject);
[Link]("jsonToCsv").innerText = csvOutput;
// d) Create hash from string (using a simple hash function for demo)
function simpleHash(str) {
let hash = 0;
for (let i = 0; i < [Link]; i++) {
hash += [Link](i);
}
return [Link]();
}
const hash = simpleHash("Hello World");
[Link]("hashOutput").innerText = `Hash of 'Hello World': ${hash}`;
</script>
</body>
</html>``````````````````````````````````````````````````````````````````