React Native : Displaying specific content from an array of objects

Viewed 29

I have Sampling_Instructions that contains an array of objects according to the example I listed below and my goal is to display only the Body information. Pay attention, green apple What is the right way to do this?

"Sampling_Instructions":"[{\"Timestamp\":\"2022-09-18T11:50:00\",\"From_User_ID\":20,\"Type\":\"Sampling_Instructions\",\"Body\":\"Pay attention\"},
{\"Timestamp\":\"2022-09-10T11:20:00\",\"From_User_ID\":20,\"Type\":\"Sampling_Instructions\",\"Body\":\"green apple\"}]",
1 Answers

Use JSON parse like this

let samplingInstructions = JSON.parse(JSON.parse( sampling instruction ))
console.log(samplingInstructions[0].Body)
Related