node.js - Parsing a string (gotten from rabbitmq) into JSON -


i using rabbittmq consume json (that got mongodb) in nodejs application. below mentioned code snippet :

        ch.consume(q, function(msg){         var clone = msg.content.tostring();         var cloned = json.parse(clone.replace(/_/g,""));         //var cloned = json.parse(clone);         console.log(' [x] recieved %s', cloned); // shows correct json          var keys = object.keys(cloned);         (var = 0; < keys.length; i++) {                  console.log('keys....', cloned[keys[i]]);         } //-----keys coming 1 character per key 

if try parse "clone", unexpected error due underscore @ position 0. , not able parse json.

and when replace underscore blank string, not able parse json error comes stating "unexpected token v in json @ position 2".

in order see if parsed correctly displaying keys. keys come

keys.... { keys.... keys.... v keys.... : keys.... keys.... 0 keys.... , keys....  keys.... keys.... keys.... f keys.... o keys.... l keys.... 

please me here !! in advance !


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -