trusted online pharmacy no prescription.
This example is similar to theA�Serializing and deserializing JSON with PHP example. JavaScript is used instead of PHP.A�Douglas Crockford’s JSON library has been used for serializing and deserializing JSON in JavaScript.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > <html lang="en"> <head> <title>JSON serialization and deserialization with JavaScript</title> <script src="json2.js"></script> <script type="text/javascript"> function jsonExample(){ var output = document.getElementById('output'); // Construct the array containing users var userArray = new Array(); userArray[0] = {'name' : 'Joe', 'occupation' : 'Student'}; userArray[1] = {'name' : 'Bob', 'occupation' : 'Miner'}; userArray[2] = {'name' : 'Betty', 'occupation' : 'Housewife'}; // Serialize and print the JSON data var serializedUsers = JSON.stringify(userArray); output.innerHTML += "Serialized: " + serializedUsers + "\n"; // Deserialize and print the array var deserializedUsers = JSON.parse(serializedUsers); output.innerHTML += "Deserialized: " + deserializedUsers + "\n"; } </script> </head> <body onload="jsonExample();"> <pre id="output"> </pre> </body> </html>
Output:
Serialized: [{"name":"Joe","occupation":"Student"},{"name":"Bob","occupation":"Miner"},{"name":"Betty","occupation":"Housewife"}] Deserialized: [object Object],[object Object],[object Object]