Package com.fasterxml.jackson.core

Examples of com.fasterxml.jackson.core.JsonToken


public class CustomDateTimeDeserializer extends JsonDeserializer<DateTime> {

    @Override
    public DateTime deserialize(JsonParser jp, DeserializationContext ctxt)
            throws IOException, JsonProcessingException {
        JsonToken t = jp.getCurrentToken();
        if (t == JsonToken.VALUE_STRING) {
            String str = jp.getText().trim();
            return ISODateTimeFormat.dateTimeParser().parseDateTime(str);
        }
        if (t == JsonToken.VALUE_NUMBER_INT) {
View Full Code Here


    private JsonElement parseContent(com.fasterxml.jackson.core.JsonParser parser) throws IOException, com.fasterxml.jackson.core.JsonParseException {
        JsonHandler handler = new JsonHandler();

        LinkedList<Boolean> stack = new LinkedList<>();
        JsonToken nextToken;
        handler.startJSON();
        while((nextToken = parser.nextToken()) != null) {
            switch (nextToken) {
            case START_OBJECT:
                handler.startObject();
View Full Code Here

  }

  @Override
  public void accept(MetricDataVisitor visitor) throws IOException {
    while (true) {
      JsonToken token = jsonParser.nextToken();
      if (token == null) {
        break;
      }

      switch (token) {
View Full Code Here

  @Override
  public final CouchbaseStorable decode(final Object source, final CouchbaseStorable target) {
    try {
      JsonParser parser = factory.createParser((String) source);
      while (parser.nextToken() != null) {
        JsonToken currentToken = parser.getCurrentToken();

        if (currentToken == JsonToken.START_OBJECT) {
          return decodeObject(parser, (CouchbaseDocument) target);
        } else if (currentToken == JsonToken.START_ARRAY) {
          return decodeArray(parser, new CouchbaseList());
View Full Code Here

   *
   * @throws IOException
   * @returns the decoded object.
   */
  private CouchbaseDocument decodeObject(final JsonParser parser, final CouchbaseDocument target) throws IOException {
    JsonToken currentToken = parser.nextToken();

    String fieldName = "";
    while (currentToken != null && currentToken != JsonToken.END_OBJECT) {
      if (currentToken == JsonToken.START_OBJECT) {
        target.put(fieldName, decodeObject(parser, new CouchbaseDocument()));
View Full Code Here

   *
   * @throws IOException
   * @returns the decoded list.
   */
  private CouchbaseList decodeArray(final JsonParser parser, final CouchbaseList target) throws IOException {
    JsonToken currentToken = parser.nextToken();

    while (currentToken != null && currentToken != JsonToken.END_ARRAY) {
      if (currentToken == JsonToken.START_OBJECT) {
        target.put(decodeObject(parser, new CouchbaseDocument()));
      } else if (currentToken == JsonToken.START_ARRAY) {
View Full Code Here

     * @param elementName
     * @param inArray if the element is in an array
     * @throws Exception
     */
    private void parseElement(final String elementName, final boolean inArray) throws Exception {
        JsonToken currentToken = jsonParser.getCurrentToken();
        if (inArray) {
            startElement(elementName);
        }
        if (START_OBJECT.equals(currentToken)) {
            parseObject();
        } else if (START_ARRAY.equals(currentToken)) {
            parseArray(elementName);
        } else if (currentToken.isScalarValue()) {
            parseValue();
        }
        if (inArray) {
            endElement(elementName);
        }
View Full Code Here

 
 
  @SuppressWarnings("unchecked")
  public T jsonRead(JsonParser parser, String path) throws IOException {
   
    JsonToken token = parser.nextToken();
    if (JsonToken.VALUE_NULL == token || JsonToken.END_ARRAY == token) {
      return null;
    }
    if (JsonToken.START_OBJECT != token) {
      throw new JsonParseException("Unexpected token "+token+" - expecting start_object", parser.getCurrentLocation());
View Full Code Here

  @SuppressWarnings("unchecked")
  protected T jsonReadProperties(JsonParser parser, EntityBean bean) throws IOException {

    do {
    
      JsonToken event = parser.nextToken();
      if (JsonToken.FIELD_NAME == event) {
        String key = parser.getCurrentName();
        BeanProperty p = desc.getBeanProperty(key);
        if (p != null) {
          p.jsonRead(parser, bean);
View Full Code Here

   
    if (!this.many.jsonDeserialize) {
      return;
    }

    JsonToken event = parser.nextToken();
    if (JsonToken.VALUE_NULL == event) {
      return;
    }
    if (JsonToken.START_ARRAY != event) {
      throw new JsonParseException("Unexpected token " + event + " - expecting start_array ", parser.getCurrentLocation());
View Full Code Here

TOP

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

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.