JSON API in Javascript

1. Serialize JavaScript object  to JSON

var messageObject = { title: 'Hello World!', body: 'It\'s great!' };
var serializedJSON = JSON.stringify( messageObject ); });

 

2. Parse JSON to Javascript Object

var serializedJSON = '{"title":"Hello World!","body":"It\'s great!"}';
var message = JSON.parse( serializedJSON );

 

posted @ 2013-10-02 17:07  Master HaKu  阅读(404)  评论(0编辑  收藏  举报