View Only
last person joined: 17 days ago 

Ask questions and share experiences with Junos Space and network management.

REST API & Malformed JSON Responses w/Compact Mode

  • 1.  REST API & Malformed JSON Responses w/Compact Mode

    Posted 07-05-2023 13:32

    When using the REST API with the export-format state-data set to json compact, responses are malformed JSON.  e.g. - get-chassis-inventory

        "chassis-inventory": {
            "chassis": {
                "name": "Chassis",
                "serial-number": "XXXXX",
                "description": "EX4100-F-12T",
                "chassis-module": {
                    "name": "PseudoCB0"
                    "name": "RoutingEngine0",
                    "part-number": "BUILTIN",
                    "serial-number": "BUILTIN",
                    "description": "RE-EX4100-F-12T",
                    "clei-code": "CMMX810BRA",
                    "model-number": "EX4100-F-12T"


    Can't highlight the malformed part, but starting at the "chassis-module" section, that's not valid JSON. That section should either be an array or an object with key=>value pairs of objects of all the sub-modules.

    The default, yet more annoying way of getting responses wraps everything in arrays. Working in this mode made me nearly rip my hair out, but then I found this export json compact note on the API's page. Got so excited. Exactly what I needed to make my life easier...

    and it's broke