ja and complex json object

Viewed 14

I'm converting a Sdmx xml api output to an Json Object. I try with boot 'xml-js' and 'xml2js' and the result is a complex object like this:

{
"_declaration": {
    "_attributes": {
        "version": "1.0",
        "encoding": "utf-8"
    }
},
"_comment": "NSI Web Service v6.16.0",
"message:Structure": {
    "_attributes": {
        "xmlns:message": "http://www.sdmx.org/resources/sdmxml/schemas/v2_1/message",
        "xmlns:structure": "http://www.sdmx.org/resources/sdmxml/schemas/v2_1/structure",
        "xmlns:common": "http://www.sdmx.org/resources/sdmxml/schemas/v2_1/common"
    },
    "message:Header": {
        "message:ID": {
            "_text": "IDREF161"
        },
        "message:Test": {
            "_text": "false"
        },
        "message:Prepared": {
            "_text": "2021-04-11T13:21:40.0658418+02:00"
        },
        "message:Sender": {
            "_attributes": {
                "id": "Unknown"
            }
        },
        "message:Receiver": {
            "_attributes": {
                "id": "Unknown"
            }
        }
    },
    "message:Structures": {
        "structure:Codelists": {
            "structure:Codelist": {
                "_attributes": {
                    "id": "CL_CAUSEMORTE_SL",
                    "urn": "urn:sdmx:org.sdmx.infomodel.codelist.Codelist=IT1:CL_CAUSEMORTE_SL(1.1)",
                    "agencyID": "IT1",
                    "version": "1.1",
                    "isFinal": "true"
                },
                "common:Name": [
                    {
                        "_attributes": {
                            "xml:lang": "it"
                        },
                        "_text": "Cause di morte - European short list"
                    },
                    {
                        "_attributes": {
                            "xml:lang": "en"
                        },
                        "_text": "European short list of causes of death"
                    }
                ],

I can't navigate the structure and retrive elements value in anyway, examples:

console.log(result['message:Structure']);

undefined

console.log(result[2]);

undefined

any help is appreciated, regards, Maurizio

0 Answers
Related