assertj-json icon indicating copy to clipboard operation
assertj-json copied to clipboard

Got exception during array assertion

Open hexwit opened this issue 8 years ago • 1 comments

Doing assertion like this: JsonPathAssert(ctx).jsonPathAsString("$.entities").isEmpty();

And got following exception:

java.lang.RuntimeException: Invalid or non Implemented status createArray() in class net.minidev.json.writer.BeansMapper$Bean
        at net.minidev.json.writer.JsonReaderI.createArray(JsonReaderI.java:98)
        at net.minidev.json.parser.JSONParserBase.readArray(JSONParserBase.java:235)
        at net.minidev.json.parser.JSONParserBase.readFirst(JSONParserBase.java:300)
        at net.minidev.json.parser.JSONParserBase.parse(JSONParserBase.java:154)
        at net.minidev.json.parser.JSONParserString.parse(JSONParserString.java:58)
        at net.minidev.json.parser.JSONParser.parse(JSONParser.java:263)
        at net.minidev.json.JSONValue.parse(JSONValue.java:206)
        at com.jayway.jsonpath.spi.mapper.JsonSmartMappingProvider.map(JsonSmartMappingProvider.java:82)
        at com.jayway.jsonpath.internal.JsonContext.convert(JsonContext.java:192)
        at com.jayway.jsonpath.internal.JsonContext.read(JsonContext.java:158)
        at com.revinate.assertj.json.JsonPathAssert.jsonPathAsString(JsonPathAssert.java:31)

Could you say what is the reason and how to fix it?

hexwit avatar May 17 '17 18:05 hexwit

Hi @hexwit,

What's the version of json-smart in your classpath? It's a transitive dependency from json-path. I was trying to troubleshoot your stacktrace against version 2.1.1 and the lines JSONParserBase.java:300 and JSONParserBase.java:235 cannot be related. I suspect you have another dependency that imports a newer version of json-smart. If that's the case I cannot be of much help because I am not familiar with this library. I often use Jackson and even the unit tests of this library uses Jackson.

However I can see by the stacktrace that the JSON parser found an array content and it is trying to parse it as string. Can you provide a simple example with this failure that I can reproduce on my end?

jrglee avatar May 19 '17 16:05 jrglee