json-path/JsonPath · error · UnsupportedOperationException
JsonOrg provider does not support TypeRef! Use a Jackson or
Error message
JsonOrg provider does not support TypeRef! Use a Jackson or Gson based provider
What it means
JsonOrgMappingProvider cannot convert to generic typed targets: its map(Object, TypeRef<T>, Configuration) implementation unconditionally throws UnsupportedOperationException. Type-based generic deserialization requires a databind library, so the message directs users to Jackson or Gson based providers.
Source
Thrown at json-path/src/main/java/com/jayway/jsonpath/spi/mapper/JsonOrgMappingProvider.java:27
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class JsonOrgMappingProvider implements MappingProvider {
@Override
public <T> T map(Object source, Class<T> targetType, Configuration configuration) {
if(source == null){
return null;
}
if(targetType.equals(Object.class) || targetType.equals(List.class) || targetType.equals(Map.class)){
return (T) mapToObject(source);
}
return (T)source;
}
@Override
public <T> T map(Object source, TypeRef<T> targetType, Configuration configuration) {
throw new UnsupportedOperationException("JsonOrg provider does not support TypeRef! Use a Jackson or Gson based provider");
}
private Object mapToObject(Object source){
if(source instanceof JSONArray){
List<Object> mapped = new ArrayList<Object>();
JSONArray array = (JSONArray) source;
for (int i = 0; i < array.length(); i++){
mapped.add(mapToObject(array.get(i)));
}
return mapped;
}
else if (source instanceof JSONObject){
Map<String, Object> mapped = new HashMap<String, Object>();
JSONObject obj = (JSONObject) source;
View on GitHub (pinned to 62a4c9f0f6)
Solutions
- Switch the mapping configuration to JacksonMappingProvider or GsonMappingProvider: Configuration.builder().mappingProvider(new JacksonMappingProvider()).build()
- Use the class-based read(path, Class<T>) overload with types JsonOrg supports, or read as raw JSONObject/JSONArray and convert manually
- Use JsonPath.using(config) everywhere so the intended provider is consistently applied
Example fix
// before
Configuration cfg = Configuration.defaultConfiguration(); // JsonOrg
List<MyDto> list = JsonPath.using(cfg).parse(json).read("$[*]", new TypeRef<List<MyDto>>(){});
// after
Configuration cfg = Configuration.builder()
.mappingProvider(new JacksonMappingProvider()).build();
List<MyDto> list = JsonPath.using(cfg).parse(json).read("$[*]", new TypeRef<List<MyDto>>(){}); Defensive patterns
Strategy: try-catch
Validate before calling
// ensure provider supports TypeRef before typed reads
if (config.getMappingProvider() instanceof JsonOrgMappingProvider) {
throw new IllegalStateException("Use Jackson/Gson mapping provider for TypeRef reads");
} Type guard
boolean supportsTypeRef(Configuration cfg) {
return !(cfg.getMappingProvider() instanceof JsonOrgMappingProvider);
} Try / catch
try {
T v = JsonPath.using(config).parse(json).read(path, new TypeRef<T>(){});
} catch (UnsupportedOperationException e) {
// provider lacks TypeRef support: switch mapping provider or use Class-based read
} Prevention
- Configure JacksonMappingProvider or GsonMappingProvider whenever you use TypeRef
- Never assume Configuration.defaultConfiguration() supports generic typed reads
- Add a startup config check that fails fast when the provider lacks TypeRef support
When it happens
Trigger: Calling JsonPath.parse(...).read(path, new TypeRef<List<MyDto>>(){}) (or any TypeRef overload) while the configuration's mapping provider is JsonOrgMappingProvider (org.json based).
Common situations: Using Configuration.defaultConfiguration() or explicitly setting the JsonOrg provider and then attempting typed reads; copying code that worked under Jackson/Gson config to a JsonOrg setup; building TypeRef support expectations from a provider-agnostic API.
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
- Json-smart provider does not support TypeRef! Use a Jackson
- 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/66d60f8e38ac8800.
Report an issue: GitHub.