-1
console.log(JSON.stringify(body));

this is a log from above code.

"{\"result\":{\"normal\":0.002,\"soft\":0.776,\"adult\":0.222}}"

this is a result of json String but I can't how to parsing normal, soft, adult value

Andres Riofrio
  • 9,851
  • 7
  • 40
  • 60
  • It looks like you are trying to turn something that is already a string into a string. (Hence the `\"` stuff. I think you really want `JSON.parse` – Jeremy J Starcher Dec 30 '19 at 05:19
  • It's suggested to search before post a new thread, as you can imagine this is a very common question so there should be some one who asked the same before, like this : https://stackoverflow.com/questions/4935632/parse-json-in-javascript – Blangero Dec 30 '19 at 05:19

1 Answers1

1

To parse the JSON string just use indexing on the key's value. Something like this would help you retrieve the value of normal in the JSON object:

console.log(body['result']['normal']);

Read up more about the JSON object and how to handle them: https://www.w3schools.com/js/js_json_objects.asp

stark
  • 399
  • 2
  • 13
  • No worries but as suggested in the comments, try searching for the question before asking :) – stark Dec 31 '19 at 04:01