Here's some code to help with basic reading of the JSON value.


For the agent:


function ping(request,res)
{

    device.send("response",http.jsondecode(request.body));
    res.send(200, "OK");
}

http.onrequest(ping);

And then for the device code:

agent.on("response",function(value) {
   
// find key "servospeed"
   if ("servospeed" in value){
       servospeed = value.servospeed.tofloat();
      // do something awesome with the servo speed value
   }
 // find key "servotoggle"  
   if ("servotoggle" in value){
       if (value.servotoggle == "0") {
           // turn servo off
       } else {
           
        // turn servo on
       }
   }
   
   
});