Skip to content

Changing JsonPathProvider to Jackson breaks the JsonPathLinkDiscoverer #1980

@BeniaminK

Description

@BeniaminK

Changing JsonPath provider to JacksonProvider breaks the createLinksFrom in JsonPathLinkDiscoverer

By setting the Configuration of the JsonPath to JacksonJsonProvider - the createLinksFrom breaks it's usage (as it relies only on JsonSmartJsonPRovider)

Configuration.setDefaults(new Configuration.Defaults() {

    private final JsonProvider jsonProvider = new JacksonJsonProvider();
    private final MappingProvider mappingProvider = new JacksonMappingProvider();
      
    @Override
    public JsonProvider jsonProvider() {
        return jsonProvider;
    }

    @Override
    public MappingProvider mappingProvider() {
        return mappingProvider;
    }
    
    @Override
    public Set<Option> options() {
        return EnumSet.noneOf(Option.class);
    }
});

breaks almost all tests in the HalLinkDiscovererUnitTest.

However adding:

if (List.class.isInstance(parseResult)) {

	List<?> list = (List<?>) parseResult;

	return list.stream()
			.flatMap(it -> List.class.isInstance(it) ? ((List<?>) it).stream() : Stream.of(it))
			.map(it -> extractLink(it, rel))
			.collect(Links.collector());
}

in the JsonPathLinkDiscoverer file fixes those Tests (however still few other tests are broken).

I think the implementation in Spring shouldn't so closely rely on using net.minidev.json packages

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions