I have JSON object result which is converted from xml data response as mentioned below.
{
"env:Envelope": {
"xmlns:env": [
"http://schemas.xmlsoap.org/soap/envelope/"
],
"xmlns:wsa": [
"http://www.w3.org/2005/08/addressing"
],
"env:Header": [
{
"wsa:MessageID": [
"urn:E8CC4000D1BF11EA8F1C35236A977E2C"
],
"wsa:FaultTo": [
{
"wsa:Address": [
"http://www.w3.org/2005/08/addressing/anonymous"
],
"wsa:ReferenceParameters": [
{
"instra:tracking.compositeInstanceCreatedTime": [
{
"_": "2020-07-29T12:21:16.054-05:00",
"xmlns:instra": [
"http://xmlns.o.com/sca/tracking/1.0"
]
}
]
}
]
}
]
}
],
"env:Body": [
{
"processResponse": [
{
"xmlns": [
"http://xmlns.o.com/BPL_AutoRFC"
],
"payload": [
{
"xmlns:dvm": [
"http://www.o.com/XSL/Transform/java/tip.dvm.LookupValue"
],
"xmlns": [
""
],
"ns0:RfcProject": [
{
"xmlns:ns0": [
"http://www.siebel.com/xml/RFC"
],
"ns0:IntegrationStatus": [
"RFC Query - Success"
],
"ns0:Id": [
"3-APXME9Y
],
]
}
]
}
}
The code am using below:
(async () => {
const { response } = await soapRequest({ url: url, headers: sampleHeaders, xml: xml, timeout: 10000 }); // Optional timeout parameter(milliseconds)
const { headers, body, statusCode } = response;
console.log(headers);
xml2js.parseString(body,{ mergeAttrs: true }, (err, result) => {
if(err) {
throw err;
}
// `result` is a JavaScript object
// convert it to a JSON string
const json = JSON.stringify(result, null, 4);
// log JSON string
console.log(json);
});
})();
I need to fetch below value from the above JSON object result. Is there anyway i can fetch the value.
Below value i need to fetch from JSON object.Also i many cases i need to fetch the value like this.
"ns0:Id": 3-APXME9Y
Can any one help in this
console.log()prints everything).resultis a JavaScript object, all you have to do is to access its properties using the square bracket notation.