gregwhitaker / catnap

Partial JSON response framework for RESTful web services
Apache License 2.0
55 stars 15 forks source link

Checking null in CatnapEqualityExpression.isEqual method for the json nodes missing elements. #13

Open Chinna-SHS opened 7 years ago

Chinna-SHS commented 7 years ago

https://github.com/gregwhitaker/catnap/blob/b637dd505b97894875f9e459aee6bb81570438d3/catnap-core/src/main/java/com/github/gregwhitaker/catnap/core/query/model/CatnapEqualityExpression.java#L80

hi Greg, In the following response scenario if the filter key is not available in some node then I am getting null pointer exception. Could you please check this below?

1) Let's say given filter is like below ?fields=items[key=1]

2) Let's say response from service is like below. "key" element is missing in third node. We are trying to filter with "key=1". In this case , line number 80 is throwing null pointer exception as there is no key and value is null. We should return false in that case. What do you think?

{"items": [ { "key": "1", "value": "v1" }, { "key": "2", "value": "v2" }, {"value": "v3"} ]}

gregwhitaker commented 6 years ago

I've got a fix for this that I can push soon.

Chinna-SHS commented 6 years ago

Thanks.