0
votes

I sometimes need to parse JSON with null in values like this:

{"someKey" : null}

and verify someKey value is null, but that seems impossible:

All other jsonPath are converted to string like this:

{"someKey" : 2}
.check(jsonPath("$.someKey").is("2")) //pass

but null:

{"someKey" : null}
.check(jsonPath("$.someKey").is("null"))
//jsonPath($.extMediaThumbnailId).find(0).is(null), but actually found nothing

.is(null) check return nullpointer exception

Maybe it is a bug Is there a way to check json value is null with jsonPath?

1

1 Answers

3
votes

It's only currently possible when explicitly setting the expected type as Any, using ofType[Any]. But you use the default, which is String.

We'll support all types in upcoming 2.2.1, see issue here.