How to safely parse json object coming through websockets?
<p>My node.js server is expecting to receive stringified JSON object from a non authenticated (not trusted) client.</p>

<p>The server uses JSON.parse to process the data.
is it possible to inject "threatening and manipulating " orders within the JOSN data coming from the websocket  ?</p>

<p>is there any security precautions to consider ?</p>

<p>is there any thing like "htmlspecialchars() in php" in the javascript parsing?</p>

<p>Server:</p>

<pre><code>wsBoss = new WSServer(portboss);
wsBoss.on('connection', function (socket) {
console.log('connected to boss');
socket.on('message', function (msg) {
    console.log(JSON.parse(msg).topGeo[0]);
    var msgsms="HI";
    socket.send(msgsms);
});
</code></pre>

<p>Client:</p>

<pre><code>var data={"topGeo":topGeo,
          "bottomGeo":bottomGeo,
          "concLoad":concLoad}
console.log(topGeo,bottomGeo,depth,generalLoad,concLoad,intervLoad,mode,joistType,units);
websocket.send(JSON.stringify(data));
</code></pre>