Package com.jayway.jsonpath.spi.mapper

Examples of com.jayway.jsonpath.spi.mapper.MappingException


                return factory.createInstance().getMapper(targetType).convert(source);
            }
            String s = configuration.jsonProvider().toJson(source);
            return (T) JSONValue.parse(s, targetType);
        } catch (Exception e) {
            throw new MappingException(e);
        }

    }
View Full Code Here


            } else if (Float.class.isAssignableFrom(src.getClass())) {
                return ((Float) src).intValue();
            } else if (String.class.isAssignableFrom(src.getClass())) {
                return Integer.valueOf(src.toString());
            }
            throw new MappingException("can not map a " + src.getClass() + " to " + Integer.class.getName());
        }
View Full Code Here

            } else if (Float.class.isAssignableFrom(src.getClass())) {
                return ((Float) src).longValue();
            } else if (String.class.isAssignableFrom(src.getClass())) {
                return Long.valueOf(src.toString());
            }
            throw new MappingException("can not map a " + src.getClass() + " to " + Long.class.getName());
        }
View Full Code Here

            } else if (Float.class.isAssignableFrom(src.getClass())) {
                return ((Float) src).doubleValue();
            } else if (String.class.isAssignableFrom(src.getClass())) {
                return Double.valueOf(src.toString());
            }
            throw new MappingException("can not map a " + src.getClass() + " to " + Double.class.getName());
        }
View Full Code Here

            } else if (Double.class.isAssignableFrom(src.getClass())) {
                return ((Double) src).floatValue();
            } else if (String.class.isAssignableFrom(src.getClass())) {
                return Float.valueOf(src.toString());
            }
            throw new MappingException("can not map a " + src.getClass() + " to " + Float.class.getName());
        }
View Full Code Here

            }
            else if(String.class.isAssignableFrom(src.getClass())){
                try {
                    return DateFormat.getInstance().parse(src.toString());
                } catch (ParseException e) {
                    throw new MappingException(e);
                }
            }
            throw new MappingException("can not map a " + src.getClass() + " to " + Date.class.getName());
        }
View Full Code Here

    @Override
    public <T> T map(Object source, Class<T> targetType, Configuration configuration) {
        try {
            return factory.createInstance().getAdapter(targetType).fromJsonTree((JsonElement) source);
        } catch (Exception e){
            throw new MappingException(e);
        }
    }
View Full Code Here

    @Override
    public <T> T map(Object source, TypeRef<T> targetType, Configuration configuration) {
        try {
            return (T) factory.createInstance().getAdapter(TypeToken.get(targetType.getType())).fromJsonTree((JsonElement) source);
        } catch (Exception e){
            throw new MappingException(e);
        }
    }
View Full Code Here

            return null;
        }
        try {
            return objectMapper.convertValue(source, targetType);
        } catch (Exception e) {
            throw new MappingException(e);
        }

    }
View Full Code Here

        JavaType type = objectMapper.getTypeFactory().constructType(targetType.getType());

        try {
            return (T)objectMapper.convertValue(source, type);
        } catch (Exception e) {
            throw new MappingException(e);
        }

    }
View Full Code Here

TOP

Related Classes of com.jayway.jsonpath.spi.mapper.MappingException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.