Reputation: 1
JSON:
{
"trackResponse": {
"shipment": [{
"warnings": [{
"code": "TW",
"message": "Tracking Information Not Found"
}]
}]
}
}
In that string I want to retrieve "message" information. Please let know
Upvotes: 0
Views: 86
Reputation: 655
use flatMap and Map
var data = {
"trackResponse": {
"shipment": [{
"warnings": [{
"code": "TW",
"message": "Tracking Information Not Found"
}]
}]
}
};
console.log(data.trackResponse.shipment.flatMap(i=>i.warnings.map(m=>m.message)))
Upvotes: 1