Package com.fasterxml.jackson.core

Examples of com.fasterxml.jackson.core.JsonParseException


        public Boolean 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 jsonParser.getBooleanValue();
View Full Code Here


        public Double 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 jsonParser.getDoubleValue();
View Full Code Here

        public Long 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 jsonParser.getLongValue();
View Full Code Here

                || initialToken == JsonToken.VALUE_NUMBER_INT) {
            rval = jp.readValueAs(Number.class);
        } else if (initialToken == JsonToken.VALUE_NULL) {
            rval = null;
        } else {
            throw new JsonParseException("document doesn't start with a valid json element : "
                    + initialToken, jp.getCurrentLocation());
        }
        return rval;
    }
View Full Code Here

    }

  }

  private static void throwE(JsonLocation l, String e) throws JsonParseException {
    throw new JsonParseException(e, l);
  }
View Full Code Here

  private static void throwE(JsonLocation l, String e) throws JsonParseException {
    throw new JsonParseException(e, l);
  }

  private static void throwE(JsonParser jp, String e) throws JsonParseException {
    throw new JsonParseException(e, jp.getCurrentLocation());
  }
View Full Code Here

      writeData(writer.rootAsList());
      break;
    case NOT_AVAILABLE:
      return false;
    default:
      throw new JsonParseException(
          String.format("Failure while parsing JSON.  Found token of [%s]  Drill currently only supports parsing "
              + "json strings that contain either lists or maps.  The root object cannot be a scalar.",
              t),
          parser.getCurrentLocation());
    }
View Full Code Here

  protected void handleAndRaise(String msg, Exception e) {
    StringBuilder sb = new StringBuilder();
    sb.append(msg).append(" - Parser was at record: ").append(recordCount+1);
    if (e instanceof JsonParseException) {
      JsonParseException ex = JsonParseException.class.cast(e);
      sb.append(" column: ").append(ex.getLocation().getColumnNr());
    }
    throw new DrillRuntimeException(sb.toString(), e);
  }
View Full Code Here

      if (ctx == null) {
        if (_currToken == JsonToken.END_OBJECT) {
          //end of input
          return null;
        }
        throw new JsonParseException("Found element outside the document",
            getTokenLocation());
      }
     
      if (ctx.state == State.DONE) {
        //next field
        ctx.reset();
      }

      boolean readValue = true;
      if (ctx.state == State.FIELDNAME) {
        readValue = false;
        while (true) {
          //read field name or end of document
          ctx.type = _in.readByte();
          if (ctx.type == BsonConstants.TYPE_END) {
            //end of document
            _currToken = (ctx.array ? JsonToken.END_ARRAY : JsonToken.END_OBJECT);
            _currentContext = _currentContext.parent;
          } else if (ctx.type == BsonConstants.TYPE_UNDEFINED) {
            //skip field name and then ignore this token
            skipCString();
            continue;
          } else {
            ctx.state = State.VALUE;
            _currToken = JsonToken.FIELD_NAME;
           
            if (ctx.array) {
              //immediately read value of array element (discard field name)
              readValue = true;
              skipCString();
              ctx.fieldName = null;
            } else {
              //read field name
              ctx.fieldName = readCString();
            }
          }
          break;
        }
      }

      if (readValue) {
        //parse element's value
        switch (ctx.type) {
        case BsonConstants.TYPE_DOUBLE:
          ctx.value = _in.readDouble();
          _currToken = JsonToken.VALUE_NUMBER_FLOAT;
          break;
         
        case BsonConstants.TYPE_STRING:
          ctx.value = readString();
          _currToken = JsonToken.VALUE_STRING;
          break;
         
        case BsonConstants.TYPE_DOCUMENT:
          _currToken = handleNewDocument(false);
          break;
         
        case BsonConstants.TYPE_ARRAY:
          _currToken = handleNewDocument(true);
          break;
         
        case BsonConstants.TYPE_BINARY:
          _currToken = handleBinary();
          break;
         
        case BsonConstants.TYPE_OBJECTID:
          ctx.value = readObjectId();
          _currToken = JsonToken.VALUE_EMBEDDED_OBJECT;
          break;
         
        case BsonConstants.TYPE_BOOLEAN:
          boolean b = _in.readBoolean();
          ctx.value = b;
          _currToken = (b ? JsonToken.VALUE_TRUE : JsonToken.VALUE_FALSE);
          break;
         
        case BsonConstants.TYPE_DATETIME:
          ctx.value = new Date(_in.readLong());
          _currToken = JsonToken.VALUE_EMBEDDED_OBJECT;
          break;
         
        case BsonConstants.TYPE_NULL:
          _currToken = JsonToken.VALUE_NULL;
          break;
         
        case BsonConstants.TYPE_REGEX:
          _currToken = handleRegEx();
          break;
         
        case BsonConstants.TYPE_DBPOINTER:
          _currToken = handleDBPointer();
          break;
         
        case BsonConstants.TYPE_JAVASCRIPT:
          ctx.value = new JavaScript(readString());
          _currToken = JsonToken.VALUE_EMBEDDED_OBJECT;
          break;
         
        case BsonConstants.TYPE_SYMBOL:
          ctx.value = readSymbol();
          _currToken = JsonToken.VALUE_EMBEDDED_OBJECT;
          break;
         
        case BsonConstants.TYPE_JAVASCRIPT_WITH_SCOPE:
          _currToken = handleJavascriptWithScope();
          break;
         
        case BsonConstants.TYPE_INT32:
          ctx.value = _in.readInt();
          _currToken = JsonToken.VALUE_NUMBER_INT;
          break;
         
        case BsonConstants.TYPE_TIMESTAMP:
          ctx.value = readTimestamp();
          _currToken = JsonToken.VALUE_EMBEDDED_OBJECT;
          break;
         
        case BsonConstants.TYPE_INT64:
          ctx.value = _in.readLong();
          _currToken = JsonToken.VALUE_NUMBER_INT;
          break;
         
        case BsonConstants.TYPE_MINKEY:
          ctx.value = "MinKey";
          _currToken = JsonToken.VALUE_STRING;
          break;
         
        case BsonConstants.TYPE_MAXKEY:
          ctx.value = "MaxKey";
          _currToken = JsonToken.VALUE_STRING;
          break;
       
        default:
          throw new JsonParseException("Unknown element type " + ctx.type,
              getTokenLocation());
        }
        ctx.state = State.DONE;
      }
    }
View Full Code Here

      case 'x':
        //unsupported
        break;
       
      default:
        throw new JsonParseException("Invalid regex", getTokenLocation());
      }
    }
    return flags;
  }
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.