nodejs merge array

Im doint some nodejs fiddling with blogposts from wordpress and geotagging of theese posts. I have integrated geolite into nodejs and from wordpress i get the client id. Here is what my nodejs code looks like for now.

native.on('data',
  function(data)
  {
    //console.log(data)
    listener.sockets.emit('notification', data);
    jsonstring = JSON.parse(data)
    var ip = jsonstring.clientip
    var geo = geoip.lookup(ip);
    console.log(ip);
    console.log(geo);
    listener.sockets.emit('geodata', geo);
  }
);

As you can see the lat / long is sent seperate from the json encoded data to the socket.

I want to merge the lat / long into "data" and sent is as 1 object. I cant figure out how to do this. i Hope someone can help me out with this.

An expando/ad-hoc property or two should suffice:

listener.sockets.emit('notification', data);
jsonstring = JSON.parse(data)
var ip = jsonstring.clientip
var geo = geoip.lookup(ip);
jsonstring.geo = geo;
// or
jsonstring.lat = geo.lat;
jsonstring.lng = geo.lng;

Add the geo information as another property of your parsed data object before emitting it:

native.on('data',
  function(data)
  {
    var obj = JSON.parse(data)
    obj.geo = geoip.lookup(obj.ip);
    listener.sockets.emit('notification', JSON.stringify(obj));
  }
);