Package com.fasterxml.jackson.core

Examples of com.fasterxml.jackson.core.JsonParseException


        @Override
        public Long extract(JsonParser jsonParser)
                throws IOException
        {
            if (!jsonParser.hasCurrentToken()) {
                throw new JsonParseException("Unexpected end of value", jsonParser.getCurrentLocation());
            }

            if (jsonParser.getCurrentToken() == START_ARRAY) {
                long length = 0;
                while (true) {
View Full Code Here


    {
        checkNotNull(jsonInput, "jsonInput is null");
        try (JsonParser jsonParser = JSON_FACTORY.createJsonParser(jsonInput.getInput())) {
            // Initialize by advancing to first token and make sure it exists
            if (jsonParser.nextToken() == null) {
                throw new JsonParseException("Missing starting token", jsonParser.getCurrentLocation());
            }

            return jsonExtractor.extract(jsonParser);
        }
    }
View Full Code Here

        @Override
        public Slice extract(JsonParser jsonParser)
                throws IOException
        {
            if (jsonParser.getCurrentToken() != START_OBJECT) {
                throw new JsonParseException("Expected a Json object", jsonParser.getCurrentLocation());
            }

            while (!jsonParser.nextFieldName(fieldName)) {
                if (!jsonParser.hasCurrentToken()) {
                    throw new JsonParseException("Unexpected end of object", jsonParser.getCurrentLocation());
                }
                if (jsonParser.getCurrentToken() == END_OBJECT) {
                    // Unable to find matching field
                    return null;
                }
View Full Code Here

        @Override
        public Slice extract(JsonParser jsonParser)
                throws IOException
        {
            if (jsonParser.getCurrentToken() != START_ARRAY) {
                throw new JsonParseException("Expected a Json array", jsonParser.getCurrentLocation());
            }

            int currentIndex = 0;
            while (true) {
                JsonToken token = jsonParser.nextToken();
                if (token == null) {
                    throw new JsonParseException("Unexpected end of array", jsonParser.getCurrentLocation());
                }
                if (token == END_ARRAY) {
                    // Index out of bounds
                    return null;
                }
View Full Code Here

        public Slice extract(JsonParser jsonParser)
                throws IOException
        {
            JsonToken token = jsonParser.getCurrentToken();
            if (token == null) {
                throw new JsonParseException("Unexpected end of value", jsonParser.getCurrentLocation());
            }
            if (!token.isScalarValue() || token == VALUE_NULL) {
                return null;
            }
            return Slices.wrappedBuffer(jsonParser.getText().getBytes(Charsets.UTF_8));
View Full Code Here

        @Override
        public Slice extract(JsonParser jsonParser)
                throws IOException
        {
            if (!jsonParser.hasCurrentToken()) {
                throw new JsonParseException("Unexpected end of value", jsonParser.getCurrentLocation());
            }

            DynamicSliceOutput dynamicSliceOutput = new DynamicSliceOutput(ESTIMATED_JSON_OUTPUT_SIZE);
            try (JsonGenerator jsonGenerator = JSON_FACTORY.createJsonGenerator(dynamicSliceOutput)) {
                jsonGenerator.copyCurrentStructure(jsonParser);
View Full Code Here

    public JsonToken nextToken() throws IOException
    {
        if (_currentReader == null) {
            int index = _decoder.readIndex();
            if (index < 0 || index >= _memberReaders.length) {
                throw new JsonParseException("Invalid index ("+index+"); union only has "
                        +_memberReaders.length+" types",
                        _parser.getCurrentLocation());
            }
            // important: remember to create new instance
            // also: must pass our parent (not this instance)
View Full Code Here

        protected JsonToken readValue(AvroParserImpl parser, BinaryDecoder decoder)
            throws IOException
        {
            int index = decoder.readIndex();
            if (index < 0 || index >= _readers.length) {
                throw new JsonParseException("Invalid index ("+index+"); union only has "
                        +_readers.length+" types",
                        parser.getCurrentLocation());
            }
            return _readers[index].readValue(parser, decoder);
        }
View Full Code Here

      {
         return UriTemplate.fromTemplate(value);
      }
      catch (MalformedUriTemplateException e)
      {
         throw new JsonParseException("Error parsing the URI Template", parser.getCurrentLocation(), e);
      }
   }
View Full Code Here

      }

      catch (JsonMappingException e)
      {
         Assert.assertTrue(e.getCause().getClass().isAssignableFrom(JsonParseException.class));
         JsonParseException jpe = (JsonParseException) e.getCause();
         Assert.assertEquals(3, jpe.getLocation().getLineNr());
         Assert.assertEquals(3, jpe.getLocation().getLineNr());
         MalformedUriTemplateException mte = (MalformedUriTemplateException) jpe.getCause();
         Assert.assertEquals(40, mte.getLocation());
      }
      catch (IOException e)
      {
         Assert.fail();
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.core.JsonParseException

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.