title: How can i make a new single json object by extracting particular fields from realtime json data using node.js
body: <p>I have the following code which publishes the json data in the specified url using mqtt.The initial data is retrieved from http.</p>
  
  <pre><code>var request = require('request');
  var JSONStream = require('JSONStream');
  var es = require('event-stream');
  var mqtt = require('mqtt');
  request({url: 'http://isaacs.couchone.com/registry/_all_docs'})
      .pipe(JSONStream.parse('rows.*'))
      .pipe(es.mapSync(function (data) {
      console.info(data);
      var client = mqtt.createClient(1883, 'localhost');
      client.publish('NewTopic', JSON.stringify(data));
      client.end();
  return data;
  }))
  </code></pre>
  
  <p>The following is the subscriber code which subscribes the data that is published (in the above code) through mqtt</p>
  
  <pre><code>var mqtt = require('mqtt');
  var client = mqtt.createClient();
  client.subscribe('NewTopic');
  client.on('message', function(topic, message) {
    console.info(message);
  });
  </code></pre>
  
  <p><strong>In the above code, I get all json data in the specified url in 'message'.I need to extract 'id' and 'value' from the received data and make it as a single JSON object and need to publish it to mqtt,so that another client can subscribe only  the 'id' and 'value' as json data.</strong></p>