Package com.fasterxml.jackson.databind

Examples of com.fasterxml.jackson.databind.JsonMappingException


                +getValueTypeDesc()+" from Integer number (int)");
    }

    public Object createFromLong(DeserializationContext ctxt, long value)
            throws IOException, JsonProcessingException {
        throw new JsonMappingException("Can not instantiate value of type "
                +getValueTypeDesc()+" from Integer number (long)");
    }
View Full Code Here


                +getValueTypeDesc()+" from Integer number (long)");
    }

    public Object createFromDouble(DeserializationContext ctxt, double value)
            throws IOException, JsonProcessingException {
        throw new JsonMappingException("Can not instantiate value of type "
                +getValueTypeDesc()+" from Floating-point number (double)");
    }
View Full Code Here

                +getValueTypeDesc()+" from Floating-point number (double)");
    }
   
    public Object createFromBoolean(DeserializationContext ctxt, boolean value)
            throws IOException, JsonProcessingException {
        throw new JsonMappingException("Can not instantiate value of type "
                +getValueTypeDesc()+" from Boolean value");
    }
View Full Code Here

        objectNode.put("type", schemaType);
        if (objectProperties != null) {
            try {
                objectNode.put("properties", _getObjectMapper().readTree(objectProperties));
            } catch (IOException e) {
                throw new JsonMappingException("Failed to parse @JsonSerializableSchema.schemaObjectPropertiesDefinition value");
            }
        }
        if (itemDefinition != null) {
            try {
                objectNode.put("items", _getObjectMapper().readTree(itemDefinition));
            } catch (IOException e) {
                throw new JsonMappingException("Failed to parse @JsonSerializableSchema.schemaItemDefinition value");
            }
        }
        // always optional, no need to specify:
        //objectNode.put("required", false);
        return objectNode;
View Full Code Here

        // First: figure out what is the fully generic delegate type:
        TypeFactory tf = provider.getTypeFactory();
        JavaType implType = tf.constructType(_converter.getClass());
        JavaType[] params = tf.findTypeParameters(implType, Converter.class);
        if (params == null || params.length != 2) {
            throw new JsonMappingException("Could not determine Converter parameterization for "
                    +implType);
        }
        // and then we can find serializer to delegate to, construct a new instance:
        JavaType delegateType = params[1];
        return withDelegate(_converter, delegateType,
View Full Code Here

            }
            String msg = "not a valid textual representation";
            if (cause != null) {
                msg += " problem: "+cause.getMessage();
            }
            JsonMappingException e = ctxt.weirdStringException(text, _valueClass, msg);
            if (cause != null) {
                e.initCause(cause);
            }
            throw e;
            // nothing to do here, yet? We'll fail anyway
        }
        if (jp.getCurrentToken() == JsonToken.VALUE_EMBEDDED_OBJECT) {
View Full Code Here

        // First: figure out what is the fully generic delegate type:
        TypeFactory tf = provider.getTypeFactory();
        JavaType implType = tf.constructType(_converter.getClass());
        JavaType[] params = tf.findTypeParameters(implType, Converter.class);
        if (params == null || params.length != 2) {
            throw new JsonMappingException("Could not determine Converter parameterization for "
                    +implType);
        }
        // and then we can find serializer to delegate to, construct a new instance:
        JavaType delegateType = params[1];
        return withDelegate(_converter, delegateType,
View Full Code Here

        }
    }

    public static IOException maybeUnwrapPath(String pathToSkip, IOException cause) {
        if ((pathToSkip != null) && (cause instanceof JsonMappingException)) {
            JsonMappingException mappingException = (JsonMappingException) cause;
            List<JsonMappingException.Reference> paths = mappingException.getPath();
            if (!paths.isEmpty()) {
                Iterator<String> pathIterator = dotSplitter.split(pathToSkip).iterator();
                Iterator<JsonMappingException.Reference> refIterator = paths.iterator();
                while (pathIterator.hasNext()) {
                    String pathToSkipPart = pathIterator.next();
                    if (!refIterator.hasNext()) {
                        return cause;
                    }
                    String nextRefField = refIterator.next().getFieldName();
                    if (!pathToSkipPart.equals(nextRefField)) {
                        return cause;
                    }
                }
                JsonMappingException unwrapped = new JsonMappingException(rootMessage(mappingException),
                                                                          mappingException.getLocation(),
                                                                          mappingException.getCause());
                if (refIterator.hasNext()) {
                    List<JsonMappingException.Reference> remainingRefs = Lists.newArrayList(refIterator);
                    for (JsonMappingException.Reference reference : Lists.reverse(remainingRefs)) {
                        unwrapped.prependPath(reference);
                    }
                }
                return unwrapped;
            }
        }
View Full Code Here

                    wrapLoc = fromConfigValue(locRef);
                }
            }
            List<JsonMappingException.Reference> paths = Lists.reverse(cause.getPath());
            if (!paths.isEmpty()) {
                JsonMappingException withLoc = new JsonMappingException(rootMessage(cause), wrapLoc, cause);
                for (JsonMappingException.Reference path : paths) {
                    withLoc.prependPath(path);
                }
                return withLoc;
            } else {
                return new JsonMappingException(rootMessage(cause), wrapLoc, cause);
            }
        }
        return cause;
    }
View Full Code Here

            if (objectNode.get(alias) != null) {
                if (matched != null) {
                    String message = String.format(
                            "no type specified, more than one key, and both %s and %s match for inlined types.",
                            matched, alias);
                    JsonMappingException exception = ctxt.instantiationException(_baseType.getRawClass(), message);
                    exception.prependPath(_baseType, matched);
                    throw exception;
                }
                matched = alias;
            }
        }
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.databind.JsonMappingException

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.