json-path/JsonPath · error · UnsupportedOperationException
Json-smart provider does not support TypeRef! Use a Jackson
Error message
Json-smart provider does not support TypeRef! Use a Jackson or Gson based provider
What it means
JsonSmartMappingProvider cannot perform generic TypeRef-based conversions; its map(Object, TypeRef<T>, Configuration) implementation always throws UnsupportedOperationException. Generic databind needs Jackson or Gson, as the message states.
Source
Thrown at json-path/src/main/java/com/jayway/jsonpath/spi/mapper/JsonSmartMappingProvider.java:94
}
if (targetType.isAssignableFrom(source.getClass())) {
return (T) source;
}
try {
if(!configuration.jsonProvider().isMap(source) && !configuration.jsonProvider().isArray(source)){
return factory.call().getMapper(targetType).convert(source);
}
String s = configuration.jsonProvider().toJson(source);
return (T) JSONValue.parse(s, targetType);
} catch (Exception e) {
throw new MappingException(e);
}
}
@Override
public <T> T map(Object source, TypeRef<T> targetType, Configuration configuration) {
throw new UnsupportedOperationException("Json-smart provider does not support TypeRef! Use a Jackson or Gson based provider");
}
private static class StringReader extends JsonReaderI<String> {
public StringReader() {
super(null);
}
public String convert(Object src) {
if(src == null){
return null;
}
return src.toString();
}
}
private static class IntegerReader extends JsonReaderI<Integer> {
public IntegerReader() {
super(null);
}
public Integer convert(Object src) {View on GitHub (pinned to 62a4c9f0f6)
Solutions
- Configure JacksonMappingProvider or GsonMappingProvider: Configuration.builder().mappingProvider(new JacksonMappingProvider()).build()
- Replace the TypeRef read with a plain class read or manual conversion from JSONObject/JSONArray
- Pass an explicit Configuration via JsonPath.using(config) instead of relying on defaults
Example fix
// before
List<MyDto> list = JsonPath.parse(json).read("$[*]", new TypeRef<List<MyDto>>(){}); // JsonSmart
// after
Configuration cfg = Configuration.builder()
.mappingProvider(new GsonMappingProvider()).build();
List<MyDto> list = JsonPath.using(cfg).parse(json).read("$[*]", new TypeRef<List<MyDto>>(){}); Defensive patterns
Strategy: try-catch
Validate before calling
// verify TypeRef capability before typed reads
if (config.getMappingProvider() instanceof JsonSmartMappingProvider) {
throw new IllegalStateException("Use Jackson/Gson mapping provider for TypeRef reads");
} Type guard
boolean supportsTypeRef(Configuration cfg) {
return !(cfg.getMappingProvider() instanceof JsonSmartMappingProvider);
} Try / catch
try {
T v = JsonPath.using(config).parse(json).read(path, new TypeRef<T>(){});
} catch (UnsupportedOperationException e) {
// JsonSmart cannot databind: reconfigure to Jackson/Gson or use Class-based read
} Prevention
- Explicitly set a Jackson/Gson mapping provider in Configuration when using TypeRef
- Pass Configuration via JsonPath.using(config) instead of relying on json-smart defaults
- Audit ServiceLoader/META-INF registrations that silently select JsonSmartMappingProvider
When it happens
Trigger: Calling read(path, TypeRef<T>) (e.g. new TypeRef<Map<String,Object>>(){}) while the configuration's mapping provider is JsonSmartMappingProvider (json-smart based, including net.minidev defaults).
Common situations: Relying on JsonSmart defaults (it's a common default provider in json-path) and then requesting typed reads; migrating code from a Jackson-configured project to one configured with json-smart; frameworks that set the smart provider via ServiceLoader discovery.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- JsonOrg provider does not support TypeRef! Use a Jackson or
- Tapestry JSON provider does not support TypeRef! Use a Jacks
- Put can not be performed to multiple properties
- Rename can not be performed to multiple properties
- setProperty operation cannot be used with
AI-assisted analysis of json-path/JsonPath@62a4c9f0f6 (2026-09-11).
Data as JSON: /api/errors/15491073d8905f16.
Report an issue: GitHub.