Tuesday, 30 May 2017

Split string by "\" Node.js

Hy everyone, I'm having some issues with split a string because when I log her value seems ok but in the final result appears "\" like,

"map":"{\"isRoot\": true, \"visible\": true}" instead of have "map":"{"isRoot": true, "visible": true}"

So I have this code

if(mapData!=undefined){
    var map = mapData.map;
    console.log("sendDeviceInfo getServicesMapInfoById map  >>>>>>>>>>>>>>>>>>>>> ", map);
    sendData.map=map;
    createLog('debug', __dirname, __filename.slice(__dirname.length + 1, -3), device.id, 'sendDeviceInfo','sendData.map 1', sendData.map);
}

And my logs:

sendDeviceInfo getServicesMapInfoById map  >>>>>>>>>>>>>>>>>>>>>  {"isRoot": true, "visible": true}
4|wscontro | [2017-05-30 12:36:03.010] - debug: /opt/wscontroller/wscontroller-service/scripts/gps GpsController 58a8c61b-f11d-4874-91df-3a5205e4145f sendDeviceInfo sendData.map 1 "{\"isRoot\": true, \"visible\": true}"

Why is this happening?



via Catia Matos

No comments:

Post a Comment