Prototype: Handling JSON
<script>
document.observe('dom:loaded', function() {
var Person = {
name: "Jesse",
age: 26,
hometown: "Grand Rapids",
siblings: ['Joe', 'Jenny', 'Justine'],
// Functions will not show up
job: function() {
return "Unemployed";
},
other: ["Dog", "Cat", "Blah"]
};
var foo = Object.toJSON(Person);
$('output').insert(foo);
// Return the JSON to the actual object
var baz = foo.evalJSON();
});
</script>
<div id="output"></div>