title: Accessing a key's value from json body
body: <p>I have sent a post request to node express server </p>
  
  <pre><code>    app.post('/addUsers', function (req, res) {
  
     var newuser =  req.body;
     console.log(newuser);
     fs.readFile( __dirname + "/" + "users.json", 'utf8', function (err, data) {
       data = JSON.parse( data );
       data["user4"] = newuser // how can i create  a user4 here currently i get an error as newsier is whole req body or something .
       console.log( data );
  //       res.end(data);
         res.end( JSON.stringify(data));
     });
  })
  </code></pre>
  
  <p>and i have got the value of newuser to console as </p>
  
  <pre><code>{ '{"user4":{"password":"killer","id":4,"profession":"kuchbhi","name":"mukesh"}}': '' }
  </code></pre>
  
  <p>The question is how can i get the value of user4  so that i can add it to the list of users .</p>
  
  <p>I was using this dictionary in swift  </p>
  
  <pre><code>                                   ["user4":["name" : "mukesh",
                                       "password" : "killer",
                                       "profession" : "kuchbhi",
                                       "id": 4]]
  </code></pre>
  
  <p>which i changed to this once knowing its not valid json </p>
  
  <pre><code>                                ["name" : "mukesh",
                                   "password" : "killer",
                                   "profession" : "kuchbhi",
                                   "id": 4]
  </code></pre>
  
  <p>and know i don't get the error but the data from server response (i have printed it in Xcode console)after adding the fourth user is quite not in the  format i think it should be , it looks like this </p>
  
  <pre><code>["user2": {
      id = 2;
      name = suresh;
      password = password2;
      profession = librarian;
  }, "user4": {
      "{\"password\":\"killer\",\"profession\":\"kuchbhi\",\"id\":4,\"name\":\"mukesh\"}" = "";
  }, "user1": {
      id = 1;
      name = mahesh;
      password = password1;
      profession = teacher;
  }, "user3": {
      id = 3;
      name = ramesh;
      password = password3;
      profession = clerk;
  }]
  </code></pre>
  
  <p>all other entries are added by me manually in users.son.
  This is what is logged into terminal console </p>
  
  <pre><code>  user4: { '{"password":"killer","profession":"kuchbhi","id":4,"name":"mukesh"}': '' } } 
  </code></pre>
  
  <p>which i still think is not good json or is it ? </p>
  
  <p>Thank you quite a novice with format conversions and servers get/post thingy .</p>