AppWorx, Dollar Universe and Sysload Community

 View Only

How to deal with multi-level json

  • 1.  How to deal with multi-level json

    Posted Apr 04, 2019 12:17 PM

    We have an API gateway that will perform tasks using CA Automic Service Orchestration;
    At some point this gateway sends a json to Automic. We can replace this gateway with a Postman, for example, called the Automic Workflow;
    We are having difficulty in:

    • Read and treat data from this json because Automic is not understanding a json structure of one more level. See below the "mp";
    • Get json can read the data on more than one level, but in its response it modifies the json structure. For example: What was "environment": "L", turns environment = L
    • Pass json to a variable within Workflow PrompSet as Automic is not mainly understanding a json LF (ENTER) and error in execution;
    • We tried to capture json values and put it into variables: &parameters#.Environment, &parameters#.platform, &parameters#.mp.vg, for exemple.

     

        {
        "service_id": "2bd2423dcccbb707f2bc9ce61ed0d88b",
        "plan_id": "542b7c78b3c99ff864155bb82d933fe6",
        "context": {
        "clusterid": "63cdf3a0-134d-11e9-85a6-7e5c1a25d90f",
        "namespace": "automation-broker",
        "platform": "kubernetes"
        },
        "parameters": {
        "Environment":"L",
        "platform":"X",
        "System":"L",
        "dpr":"0",
        "sigla":"AUTO",
        "net":"172.1.1.0",
        "vlan":"85",
        "gateway":"17.17.16.254",
        "mascara":"255.255.255.0",
        "solicitante":"f822222",
        "ramal":"46750",
        "email":"john@email.com.br",
        "observacao":"teste_automic",
        "zone":"teste_big_data.",
        "tipo":"A",
        "ttl":"60",
        "descricao":"teste_automic",
        "vcenter":"172.2.1.21",
        "cluster_name":"lab-01",
        "datastore_cluster":"dsc-Lab-01",
        "folder":"automic",
        "template":"Matriz_CENTOS-7.6.0",
        "disk_size":"20",
        "mp": {
                "vg": "",
                "mps":     [
                            { "mp": "/", "tamanho": "10" },
                            { "mp": "/usr", "tamanho": "30" }
                        ]
        },
        "vcpus":"2",
        "memory":"8",
        "cores_per_socket":"1",
        "vm_state":"poweron",
        "domain":"domain.com.br"
        }
        }

     

     

    When we have line break in json, Automic return@:

    {
    "code": 45106,
    "error": "The request is invalid and can not be processed by the Automation Engine.",
    (CTRL-CHAR, code 13)): has to be escaped using backslash to be included in string value \ n [Source: HttpInputOverHTTP @ 21dd5ffd [c = 1247, q = 0, 0] = null, s = STREAM]; line: 5, column: 85] "
    }

     

    Alcir