JSON Path Assertion: Assert key exists in object

420 views
Skip to first unread message

Bert

unread,
Oct 19, 2016, 8:16:40 AM10/19/16
to jmeter-plugins
How can I verify that a JSON object contains a key?

In the following JSON object the age is missing for the second person, Kevin:

[
{
"name":"John",
"age":30
},
{
"name":"Kevin"
}
]


If I query the JSON Path
$[*].age
and check expected value for
\d+
then then Kevin's object gets silently ignored.

  1. I know Jayway's JsonPath, which afaik the JSON Path Assertion plugin is using, has an option (DEFAULT_PATH_LEAF_TO_NULL) to show missing leaves as null. For this case I have already a query to recognize objects with null values. But I don't know how
     to activate this option in the plugin.
  2. Is there another way to check for missing keys? A query or setting in the plugin itself?

Reply all
Reply to author
Forward
0 new messages