ECMAScript 5 Strict Mode, JSON, ….

 ECMAScript 5 Strict Mode, JSON, and More.

json2.js

JSON.parse( text )

JSON.parse( text, translate )

function translate(key, value) {
  if ( key === “name” ) {
    return value + ” Resig”;
  }
}

var obj = JSON.parse(‘{“name”:”John”,”last”:”Resig”}’, translate);
// Prints ‘John Resig’
print( obj.name );

// Undefined
print( obj.last );

JSON.stringify( obj, null, 2 )

var str = JSON.stringify({ name“John” }null2);
// Prints:
// {
//   “name”: “John”
// }
print( str );

JSON.stringify( obj, null, “\t” )

 

 

 

ö

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s