JsonPath JUnit escape character for dots

后端 未结 3 1095
情书的邮戳
情书的邮戳 2020-12-05 14:54

I have a json field which is called template.welcome.email and I am writing a unit test that checks if that field is present in the reply from the server but I can\'t find a

3条回答
  •  天涯浪人
    2020-12-05 15:30

    As Ida pointed out:

    Use brackets and quotes around your field. For example, if your field is valid.key.with.dot

    Refer to it as ['valid.key.with.dot'] and in JsonPath, try

    JsonPath.read(jsonString, "$.['valid.key.with.dot']")

提交回复
热议问题