spinjar.com.jayway.jsonpath.spi.mapper.JsonOrgMappingProvider Maven / Gradle / Ivy
package com.jayway.jsonpath.spi.mapper;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.TypeRef;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class JsonOrgMappingProvider implements MappingProvider {
@Override
public T map(Object source, Class 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 map(Object source, TypeRef 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
© 2015 - 2024 Weber Informatics LLC | Privacy Policy