json-path / JsonPath

Java JsonPath implementation
Apache License 2.0
8.94k stars 1.65k forks source link

JsonParser is not working with Records #918

Open pushpanktugnawat opened 1 year ago

pushpanktugnawat commented 1 year ago

Hey Team,

I am facing a problem accessing a records object with jsonpath. And I can see some error is happening with Jsonparser beneth.

Please find stacktrace for more info and help me with it.

at net.minidev.json.writer.BeansMapper$Bean.createObject(BeansMapper.java:93)
    at net.minidev.json.parser.JSONParserBase.readObject(JSONParserBase.java:559)
    at net.minidev.json.parser.JSONParserBase.readFirst(JSONParserBase.java:363)
    at net.minidev.json.parser.JSONParserBase.parse(JSONParserBase.java:216)
    at net.minidev.json.parser.JSONParserString.parse(JSONParserString.java:58)
    at net.minidev.json.parser.JSONParser.parse(JSONParser.java:278)
    at net.minidev.json.JSONValue.parse(JSONValue.java:201)
    at com.jayway.jsonpath.spi.mapper.JsonSmartMappingProvider.map(JsonSmartMappingProvider.java:85)
    at com.jayway.jsonpath.internal.JsonContext.convert(JsonContext.java:117)
    at com.jayway.jsonpath.internal.JsonContext.read(JsonContext.java:82)
    at org.springframework.test.util.JsonPathExpectationsHelper.evaluateJsonPath(JsonPathExpectationsHelper.java:318)
    ... 83 more
SingingBush commented 1 year ago

The issue is in json-smart, it doesn't support Records: https://github.com/netplex/json-smart-v2/issues/78

It's probably worth trying one of the other mapping providers (JacksonMappingProvider, GsonMappingProvider, or JakartaJsonProvider) instead of the default JsonSmartMappingProvider.

@kallestenflo From the project description in the readme for json-smart, it seems like it isn't going to be actively developed. Perhaps it would be better if json path deprecates JsonSmartMappingProvider and instead defaults to one of the other ones. It also doesn't support JPMS.

DevDengChao commented 1 year ago

Perhaps it would be better if json path deprecates JsonSmartMappingProvider and instead defaults to one of the other ones.

Is there any plans to do that ?