Layer 7 API Management

Expand all | Collapse all

JSON expression containing dot

Jump to Best Answer
  • 1.  JSON expression containing dot

    Posted 08-06-2019 05:39 PM
    I have a JSON that contains dot(.) in some of key. How do I extract the value of a specific key (that contains dot in it) using 'Evaluate JSON path expression'.

    As a sample in the below JSON, how do I extract the value of Vrm.DataCenter.Location
    I obviously cannot use $.data.ubuntu_Server_1.data.Vrm.DataCenter.Location in the expression.
    Please help

    {

    "data": {
    "ubuntu_Server_1": {

    "classId": "Component.Declaration",
    "typeFilter": "ubuntu_Server_1",
    "data": {

    "Vrm.DataCenter.Location": "POK",
    "lease.days": 3
    }
    }
    }
    }


  • 2.  RE: JSON expression containing dot
    Best Answer

    Posted 08-06-2019 07:29 PM
    Dear Maddy,
    It's a problem of old json path lib, you may need "Evaluate JSON Path Expression V2" assertion (available since gateway 9.3)
    The following expression works for your sample json,

    $.data.ubuntu_Server_1.data["Vrm.DataCenter.Location"]


    Regards,
    Mark



  • 3.  RE: JSON expression containing dot

    Posted 08-06-2019 08:13 PM
    Thanks a lot Mark. I am able to extract the value with that.