Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Now that you have created a simple JSON-based web service, you can write a client to consume the data and do something with it. For this, you use a standard Node.js HTTP client and parse the data that you receive using JSON.parse.
The JSON.parse method parses a JSON string, reconstructing the original JavaScript object. You can see this at work by extending the earlier example to first convert a JavaScript object to JSON and then convert it back again:
var obj = {
name : "Officer",
surname : "Dibble"
}
console.log('JavaScript object:');
console.log(obj);
var json = JSON.stringify(obj);
console.log('JavaScript object to JSON:');
console.log(json);
var parsedJson = JSON.parse(json);
console.log('JSON to JavaScript object:');
console.log(parsedJson);