Forum Discussion

dvjana's avatar
dvjana
New Contributor
8 years ago

JSONPath match filter by property name containing brackets

version: SoapUI 5.3.0

 

Currently I have difficulties with matching JSON property value, which has brackets in it. Query perfectly worked with names, containing commas, dashes and other special characters.

I am using following query, and it gives empty array as a result [].

 

$priceArray[?(@.size.name == '1 EUR (0-10 kg)')].price
{
  "priceArray": [
    {
      "id": 1,
      "size": {
        "id": 1,
        "name": "1 EUR (0-10 kg)",
        "description": "Descrition size up to 10 kg."
      },
      "price": 55.5
    }
  ]
}

 

  • The JSONPath should be valid with brackets but could be a defect

    A script assertion workaround.

     

    import groovy.json.JsonSlurper
    jsonResponse = new JsonSlurper().parseText(context.response)
    price = jsonResponse.priceArray.find { it.size.name == '1 EUR (0-10 kg)' }.price
    assert price == 55.5

     

  • PaulMS's avatar
    PaulMS
    Super Contributor

    The JSONPath should be valid with brackets but could be a defect

    A script assertion workaround.

     

    import groovy.json.JsonSlurper
    jsonResponse = new JsonSlurper().parseText(context.response)
    price = jsonResponse.priceArray.find { it.size.name == '1 EUR (0-10 kg)' }.price
    assert price == 55.5