Wednesday, 3 May 2017

How to convert a response to full json format

I have the next response:

{
  "Status": 200,
  "Email": "aristos@gmail.com",
  "Values": "[\"{\\\"name\\\":\\\"John\\\",\\\"age\\\":30,\\\"ids\\\":[ \\\"123445\\\", \\\"2345456\\\", \\\"42346\\\" ]}\"]"
}

I want to fix this part:

  "Values": "[\"{\\\"name\\\":\\\"John\\\",\\\"age\\\":30,\\\"ids\\\":[ \\\"123445\\\", \\\"2345456\\\", \\\"42346\\\" ]}\"]"

So it looks better like this:

{ Status: 200,
  Email: 'aristos@gmail.com',
  Values:  '{"name":"John","age":30,"ids":[ "123445", "2345456", "42346" ]}'  }

I'm using node js.

    var result={Status: 200,
        Email: req.body.email,
      Values: req.body.values};

Regards



via arnoldssss

No comments:

Post a Comment