-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
JsonSmartJsonProvider and JacksonJsonProvider have different array creation logic:
https://github.com/json-path/JsonPath/blob/master/json-path/src/main/java/com/jayway/jsonpath/spi/json/JsonSmartJsonProvider.java#L53
https://github.com/json-path/JsonPath/blob/master/json-path/src/main/java/com/jayway/jsonpath/spi/json/JacksonJsonProvider.java#L113
This cases output format changings on json parsing.
For example in we use the following code we will see different output.
`package com.example;
import com.jayway.jsonpath.*;
import com.jayway.jsonpath.spi.json.JacksonJsonProvider;
import com.jayway.jsonpath.spi.json.JsonSmartJsonProvider;
public class Demo {
public static void main(String[] args) throws Exception {
String json = "{\"Request\": \"12345\",\"ERR\":[{\"field\":\"ADD\",\"keyword\":\"MustHaveAdd\",\"entity\":\"TEST\"}]}";
Configuration configuration1 = Configuration.builder()
.jsonProvider(new JsonSmartJsonProvider())
.build();
Configuration configuration2 = Configuration.builder()
.jsonProvider(new JacksonJsonProvider())
.build();
Object parced1 = JsonPath.using(configuration1).parse(json).read("$.ERR[*]", new Predicate[0]);
Object parced2 = JsonPath.using(configuration2).parse(json).read("$.ERR[*]", new Predicate[0]);
System.out.println(parced1); //JsonSmartJsonProvider
System.out.println(parced2); //JacksonJsonProvider
}
}
Console output:[{"field":"ADD","keyword":"MustHaveAdd","entity":"TEST"}]
[{field=ADD, keyword=MustHaveAdd, entity=TEST}]`
Is it possible to make some unique array output type for all providers?
Now we use the following fix ArtemMarchukQlikCom@7ac8104
to set the same output in JacksonJsonProvider as it was in JsonSmartJsonProvider