Bryan Bryan - 21 days ago 5
Javascript Question

How to get certain data from JSON

How do I classify the data in JSON returned by the API with javascript.

The data given by the API:

{
"referenceNumber":"55f97f3be4b0503165e858c5",
"phoneNumber":"7877599999",
"amount":15.00,
"transStatus":"COMPLETED",
"responseStatus":{
"status":"SUCCESS",
"statusDescription":"The request is successful."
}
}


I want to receive the number from
phoneNumber
with javascript.

Answer
var data = JSON.parse(apiResponse);

var phoneNumber = data.phoneNumber;