Java Code Examples for com.fasterxml.jackson.core.JsonParser#currentToken()

The following examples show how to use com.fasterxml.jackson.core.JsonParser#currentToken() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BindBean2SharedPreferences.java    From kripton with Apache License 2.0 6 votes vote down vote up
/**
 * for attribute valueBean parsing
 */
protected Bean2 parseValueBean(String input) {
  if (input==null) {
    return null;
  }
  KriptonJsonContext context=KriptonBinder.jsonBind();
  try (JacksonWrapperParser wrapper=context.createParser(input)) {
    JsonParser jacksonParser=wrapper.jacksonParser;
    // START_OBJECT
    jacksonParser.nextToken();
    Bean2 result=null;
    if (jacksonParser.currentToken()==JsonToken.START_OBJECT) {
      result=bean2BindMap.parseOnJackson(jacksonParser);
    }
    return result;
  } catch(Exception e) {
    e.printStackTrace();
    throw(new KriptonRuntimeException(e.getMessage()));
  }
}
 
Example 2
Source File: SnapshotParser.java    From synapse with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private <T> void processSnapshotData(final JsonParser parser,
                                     final ChannelPosition channelPosition,
                                     final MessageDispatcher messageDispatcher) throws IOException {
    final Decoder<SnapshotMessage> decoder = new SnapshotMessageDecoder();
    final ShardPosition shardPosition = channelPosition.shard(channelPosition.shards().iterator().next());
    while (parser.nextToken() != JsonToken.END_ARRAY) {
        JsonToken currentToken = parser.currentToken();
        if (currentToken == JsonToken.FIELD_NAME) {
            final TextMessage message = decoder.apply(new SnapshotMessage(
                    Key.of(parser.getValueAsString()),
                    Header.of(shardPosition),
                    parser.nextTextValue()));
            messageDispatcher.accept(message);
        }
    }
}
 
Example 3
Source File: AssetDeserializer.java    From steem-java-api-wrapper with GNU General Public License v3.0 6 votes vote down vote up
@Override
public LegacyAsset deserialize(JsonParser jasonParser, DeserializationContext deserializationContext) throws IOException {
    JsonToken currentToken = jasonParser.currentToken();
    if (currentToken != null && JsonToken.VALUE_STRING.equals(currentToken)) {
        String[] assetFields = jasonParser.getText().split(" ");

        if (assetFields.length == 2) {
            /*
             * Set the symbol first which calculates the precision
             * internally. internally.
             *
             * The amount is provided as a double value while we need a long
             * value for the byte representation so we transform the amount
             * into a long value here.
             */
            return new LegacyAsset(new BigDecimal(assetFields[0]), LegacyAssetSymbolType.valueOf(assetFields[1]));
        }
    }

    throw new IllegalArgumentException("Found '" + currentToken + "' instead of '" + JsonToken.VALUE_STRING + "'.");
}
 
Example 4
Source File: BindBean2SharedPreferences.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * for attribute valueDoubleSet parsing
 */
protected HashSet<Double> parseValueDoubleSet(String input) {
  if (input==null) {
    return null;
  }
  KriptonJsonContext context=KriptonBinder.jsonBind();
  try (JacksonWrapperParser wrapper=context.createParser(input)) {
    JsonParser jacksonParser=wrapper.jacksonParser;
    // START_OBJECT
    jacksonParser.nextToken();
    // value of "element"
    jacksonParser.nextValue();
    HashSet<Double> result=null;
    if (jacksonParser.currentToken()==JsonToken.START_ARRAY) {
      HashSet<Double> collection=new HashSet<>();
      Double item=null;
      while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
        if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) {
          item=null;
        } else {
          item=jacksonParser.getDoubleValue();
        }
        collection.add(item);
      }
      result=collection;
    }
    return result;
  } catch(Exception e) {
    e.printStackTrace();
    throw(new KriptonRuntimeException(e.getMessage()));
  }
}
 
Example 5
Source File: Bean205BindMap.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * parse with jackson
 */
@Override
public Bean205 parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
  Bean205 instance = new Bean205();
  String fieldName;
  if (jacksonParser.getCurrentToken() == null) {
    jacksonParser.nextToken();
  }
  if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
    jacksonParser.skipChildren();
    return instance;
  }
  while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
    fieldName = jacksonParser.getCurrentName();
    jacksonParser.nextToken();

    // Parse fields:
    switch (fieldName) {
        case "id":
          // field id (mapped with "id")
          instance.setId(PrimitiveUtils.readLong(jacksonParser.getText(), 0L));
        break;
        case "name":
          // field name (mapped with "name")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.name=jacksonParser.getText();
          }
        break;
        case "surname":
          // field surname (mapped with "surname")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.surname=jacksonParser.getText();
          }
        break;
        default:
          jacksonParser.skipChildren();
        break;}
  }
  return instance;
}
 
Example 6
Source File: ByteBeanTable.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * for attribute value parsing
 */
public static List<Byte> parseValue(byte[] input) {
  if (input==null) {
    return null;
  }
  KriptonJsonContext context=KriptonBinder.jsonBind();
  try (JacksonWrapperParser wrapper=context.createParser(input)) {
    JsonParser jacksonParser=wrapper.jacksonParser;
    // START_OBJECT
    jacksonParser.nextToken();
    // value of "element"
    jacksonParser.nextValue();
    List<Byte> result=null;
    if (jacksonParser.currentToken()==JsonToken.START_ARRAY) {
      ArrayList<Byte> collection=new ArrayList<>();
      Byte item=null;
      while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
        if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) {
          item=null;
        } else {
          item=jacksonParser.getByteValue();
        }
        collection.add(item);
      }
      result=collection;
    }
    return result;
  } catch(Exception e) {
    e.printStackTrace();
    throw(new KriptonRuntimeException(e.getMessage()));
  }
}
 
Example 7
Source File: PersonBindMap.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * parse with jackson
 */
@Override
public Person parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
  Person instance = new Person();
  String fieldName;
  if (jacksonParser.getCurrentToken() == null) {
    jacksonParser.nextToken();
  }
  if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
    jacksonParser.skipChildren();
    return instance;
  }
  while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
    fieldName = jacksonParser.getCurrentName();
    jacksonParser.nextToken();

    // Parse fields:
    switch (fieldName) {
        case "id":
          // field id (mapped with "id")
          instance.id=PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
        break;
        case "name":
          // field name (mapped with "name")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.name=jacksonParser.getText();
          }
        break;
        default:
          jacksonParser.skipChildren();
        break;}
  }
  return instance;
}
 
Example 8
Source File: FriendBindMap.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * parse with jackson
 */
@Override
public Friend parseOnJackson(JsonParser jacksonParser) throws Exception {
  Friend instance = new Friend();
  String fieldName;
  if (jacksonParser.currentToken() == null) {
    jacksonParser.nextToken();
  }
  if (jacksonParser.currentToken() != JsonToken.START_OBJECT) {
    jacksonParser.skipChildren();
    return instance;
  }
  while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
    fieldName = jacksonParser.getCurrentName();
    jacksonParser.nextToken();

    // Parse fields:
    switch (fieldName) {
        case "id":
          // field id (mapped with "id")
          instance.id=jacksonParser.getIntValue();
        break;
        case "name":
          // field name (mapped with "name")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.name=jacksonParser.getText();
          }
        break;
        default:
          jacksonParser.skipChildren();
        break;}
  }
  return instance;
}
 
Example 9
Source File: BindBean2SharedPreferences.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * for attribute valueCharList parsing
 */
protected LinkedList<Character> parseValueCharList(String input) {
  if (input==null) {
    return null;
  }
  KriptonJsonContext context=KriptonBinder.jsonBind();
  try (JacksonWrapperParser wrapper=context.createParser(input)) {
    JsonParser jacksonParser=wrapper.jacksonParser;
    // START_OBJECT
    jacksonParser.nextToken();
    // value of "element"
    jacksonParser.nextValue();
    LinkedList<Character> result=null;
    if (jacksonParser.currentToken()==JsonToken.START_ARRAY) {
      LinkedList<Character> collection=new LinkedList<>();
      Character item=null;
      while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
        if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) {
          item=null;
        } else {
          item=Character.valueOf((char)jacksonParser.getIntValue());
        }
        collection.add(item);
      }
      result=collection;
    }
    return result;
  } catch(Exception e) {
    e.printStackTrace();
    throw(new KriptonRuntimeException(e.getMessage()));
  }
}
 
Example 10
Source File: BeanA_2BindMap.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * parse with jackson
 */
@Override
public BeanA_2 parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
  BeanA_2 instance = new BeanA_2();
  String fieldName;
  if (jacksonParser.getCurrentToken() == null) {
    jacksonParser.nextToken();
  }
  if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
    jacksonParser.skipChildren();
    return instance;
  }
  while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
    fieldName = jacksonParser.getCurrentName();
    jacksonParser.nextToken();

    // Parse fields:
    switch (fieldName) {
        case "id":
          // field id (mapped with "id")
          instance.id=PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
        break;
        case "valueString2":
          // field valueString2 (mapped with "valueString2")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.valueString2=jacksonParser.getText();
          }
        break;
        default:
          jacksonParser.skipChildren();
        break;}
  }
  return instance;
}
 
Example 11
Source File: CharBeanTable.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * for attribute value parsing
 */
public static char[] parseValue(byte[] input) {
  if (input==null) {
    return null;
  }
  KriptonJsonContext context=KriptonBinder.jsonBind();
  try (JacksonWrapperParser wrapper=context.createParser(input)) {
    JsonParser jacksonParser=wrapper.jacksonParser;
    // START_OBJECT
    jacksonParser.nextToken();
    // value of "element"
    jacksonParser.nextValue();
    char[] result=null;
    if (jacksonParser.currentToken()==JsonToken.START_ARRAY) {
      ArrayList<Character> collection=new ArrayList<>();
      Character item=null;
      while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
        if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) {
          item=null;
        } else {
          item=Character.valueOf((char)jacksonParser.getIntValue());
        }
        collection.add(item);
      }
      result=CollectionUtils.asCharacterTypeArray(collection);
    }
    return result;
  } catch(Exception e) {
    e.printStackTrace();
    throw(new KriptonRuntimeException(e.getMessage()));
  }
}
 
Example 12
Source File: Bean81MBindMap.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * parse with jackson
 */
@Override
public Bean81M parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
  Bean81M instance = new Bean81M();
  String fieldName;
  if (jacksonParser.getCurrentToken() == null) {
    jacksonParser.nextToken();
  }
  if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
    jacksonParser.skipChildren();
    return instance;
  }
  while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
    fieldName = jacksonParser.getCurrentName();
    jacksonParser.nextToken();

    // Parse fields:
    switch (fieldName) {
        case "valueString1":
          // field valueString1 (mapped with "valueString1")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.valueString1=jacksonParser.getText();
          }
        break;
        case "id":
          // field id (mapped with "id")
          instance.id=PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
        break;
        case "valueString2":
          // field valueString2 (mapped with "valueString2")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.valueString2=jacksonParser.getText();
          }
        break;
        default:
          jacksonParser.skipChildren();
        break;}
  }
  return instance;
}
 
Example 13
Source File: BeanTable.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * for attribute valueEnumTypeSet parsing
 */
public static HashSet<EnumType> parseValueEnumTypeSet(byte[] input) {
  if (input==null) {
    return null;
  }
  KriptonJsonContext context=KriptonBinder.jsonBind();
  try (JacksonWrapperParser wrapper=context.createParser(input)) {
    JsonParser jacksonParser=wrapper.jacksonParser;
    // START_OBJECT
    jacksonParser.nextToken();
    // value of "element"
    jacksonParser.nextValue();
    HashSet<EnumType> result=null;
    if (jacksonParser.currentToken()==JsonToken.START_ARRAY) {
      HashSet<EnumType> collection=new HashSet<>();
      EnumType item=null;
      while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
        if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) {
          item=null;
        } else {
           {
            String tempEnum=jacksonParser.getText();
            item=StringUtils.hasText(tempEnum)?EnumType.valueOf(tempEnum):null;
          }
        }
        collection.add(item);
      }
      result=collection;
    }
    return result;
  } catch(Exception e) {
    e.printStackTrace();
    throw(new KriptonRuntimeException(e.getMessage()));
  }
}
 
Example 14
Source File: NativeBindMap.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * parse with jackson
 */
@Override
public Native parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
  Native instance = new Native();
  String fieldName;
  if (jacksonParser.getCurrentToken() == null) {
    jacksonParser.nextToken();
  }
  if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
    jacksonParser.skipChildren();
    return instance;
  }
  while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
    fieldName = jacksonParser.getCurrentName();
    jacksonParser.nextToken();

    // Parse fields:
    switch (fieldName) {
        case "nld":
          // field nld (mapped with "nld")
          if (jacksonParser.currentToken()==JsonToken.START_OBJECT || jacksonParser.currentToken()==JsonToken.VALUE_STRING) {
            instance.nld=nldBindMap.parseOnJacksonAsString(jacksonParser);
          }
        break;
        case "pap":
          // field pap (mapped with "pap")
          if (jacksonParser.currentToken()==JsonToken.START_OBJECT || jacksonParser.currentToken()==JsonToken.VALUE_STRING) {
            instance.pap=papBindMap.parseOnJacksonAsString(jacksonParser);
          }
        break;
        default:
          jacksonParser.skipChildren();
        break;}
  }
  return instance;
}
 
Example 15
Source File: AddressBindMap.java    From kripton with Apache License 2.0 5 votes vote down vote up
/**
 * parse with jackson
 */
@Override
public Address parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
  Address instance = new Address();
  String fieldName;
  if (jacksonParser.getCurrentToken() == null) {
    jacksonParser.nextToken();
  }
  if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
    jacksonParser.skipChildren();
    return instance;
  }
  while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
    fieldName = jacksonParser.getCurrentName();
    jacksonParser.nextToken();

    // Parse fields:
    switch (fieldName) {
        case "city":
          // field city (mapped with "city")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.city=jacksonParser.getText();
          }
        break;
        case "street":
          // field street (mapped with "street")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.street=jacksonParser.getText();
          }
        break;
        default:
          jacksonParser.skipChildren();
        break;}
  }
  return instance;
}
 
Example 16
Source File: Security47BindMap.java    From kripton with Apache License 2.0 4 votes vote down vote up
/**
 * parse with jackson
 */
@Override
public Security47 parseOnJackson(JsonParser jacksonParser) throws Exception {
  Security47 instance = new Security47();
  String fieldName;
  if (jacksonParser.currentToken() == null) {
    jacksonParser.nextToken();
  }
  if (jacksonParser.currentToken() != JsonToken.START_OBJECT) {
    jacksonParser.skipChildren();
    return instance;
  }
  while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
    fieldName = jacksonParser.getCurrentName();
    jacksonParser.nextToken();

    // Parse fields:
    switch (fieldName) {
        case "authorizationToken":
          // field authorizationToken (mapped with "authorizationToken")
          if (jacksonParser.currentToken()==JsonToken.START_OBJECT) {
            instance.authorizationToken=deviceAccessTokenBindMap.parseOnJackson(jacksonParser);
          }
        break;
        case "deviceUid":
          // field deviceUid (mapped with "deviceUid")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.deviceUid=jacksonParser.getText();
          }
        break;
        case "fcmId":
          // field fcmId (mapped with "fcmId")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.fcmId=jacksonParser.getText();
          }
        break;
        case "userIdentity":
          // field userIdentity (mapped with "userIdentity")
          if (jacksonParser.currentToken()==JsonToken.START_OBJECT) {
            instance.userIdentity=userIdentityBindMap.parseOnJackson(jacksonParser);
          }
        break;
        default:
          jacksonParser.skipChildren();
        break;}
  }
  return instance;
}
 
Example 17
Source File: PersonBindMap.java    From kripton with Apache License 2.0 4 votes vote down vote up
/**
 * parse with jackson
 */
@Override
public Person parseOnJackson(JsonParser jacksonParser) throws Exception {
  Person instance = new Person();
  String fieldName;
  if (jacksonParser.currentToken() == null) {
    jacksonParser.nextToken();
  }
  if (jacksonParser.currentToken() != JsonToken.START_OBJECT) {
    jacksonParser.skipChildren();
    return instance;
  }
  while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
    fieldName = jacksonParser.getCurrentName();
    jacksonParser.nextToken();

    // Parse fields:
    switch (fieldName) {
        case "birthday":
          // field birthday (mapped with "birthday")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.birthday=DateUtils.read(jacksonParser.getText());
          }
        break;
        case "name":
          // field name (mapped with "name")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.name=jacksonParser.getText();
          }
        break;
        case "surname":
          // field surname (mapped with "surname")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.surname=jacksonParser.getText();
          }
        break;
        case "tags":
          // field tags (mapped with "tags")
          if (jacksonParser.currentToken()==JsonToken.START_ARRAY) {
            ArrayList<String> collection=new ArrayList<>();
            String item=null;
            while (jacksonParser.nextToken() != JsonToken.END_ARRAY) {
              if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) {
                item=null;
              } else {
                item=jacksonParser.getText();
              }
              collection.add(item);
            }
            instance.tags=collection;
          }
        break;
        default:
          jacksonParser.skipChildren();
        break;}
  }
  return instance;
}
 
Example 18
Source File: PrefixConfigBindMap.java    From kripton with Apache License 2.0 4 votes vote down vote up
/**
 * parse with jackson
 */
@Override
public PrefixConfig parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
  PrefixConfig instance = new PrefixConfig();
  String fieldName;
  if (jacksonParser.getCurrentToken() == null) {
    jacksonParser.nextToken();
  }
  if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
    jacksonParser.skipChildren();
    return instance;
  }
  while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
    fieldName = jacksonParser.getCurrentName();
    jacksonParser.nextToken();

    // Parse fields:
    switch (fieldName) {
        case "defaultCountry":
          // field defaultCountry (mapped with "defaultCountry")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.defaultCountry=jacksonParser.getText();
          }
        break;
        case "dialogTimeout":
          // field dialogTimeout (mapped with "dialogTimeout")
          instance.dialogTimeout=PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
        break;
        case "dualBillingPrefix":
          // field dualBillingPrefix (mapped with "dualBillingPrefix")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.dualBillingPrefix=jacksonParser.getText();
          }
        break;
        case "enabled":
          // field enabled (mapped with "enabled")
          instance.enabled=PrimitiveUtils.readBoolean(jacksonParser.getText(), (boolean)false);
        break;
        case "id":
          // field id (mapped with "id")
          instance.id=PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
        break;
        default:
          jacksonParser.skipChildren();
        break;}
  }
  return instance;
}
 
Example 19
Source File: PostBindMap.java    From kripton with Apache License 2.0 4 votes vote down vote up
/**
 * parse with jackson
 */
@Override
public Post parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
  Post instance = new Post();
  String fieldName;
  if (jacksonParser.getCurrentToken() == null) {
    jacksonParser.nextToken();
  }
  if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
    jacksonParser.skipChildren();
    return instance;
  }
  while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
    fieldName = jacksonParser.getCurrentName();
    jacksonParser.nextToken();

    // Parse fields:
    switch (fieldName) {
        case "body":
          // field body (mapped with "body")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.body=jacksonParser.getText();
          }
        break;
        case "id":
          // field id (mapped with "id")
          instance.id=PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
        break;
        case "title":
          // field title (mapped with "title")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.title=jacksonParser.getText();
          }
        break;
        case "userId":
          // field userId (mapped with "userId")
          instance.userId=PrimitiveUtils.readLong(jacksonParser.getText(), 0L);
        break;
        default:
          jacksonParser.skipChildren();
        break;}
  }
  return instance;
}
 
Example 20
Source File: NameBindMap.java    From kripton with Apache License 2.0 4 votes vote down vote up
/**
 * parse with jackson
 */
@Override
public Name parseOnJacksonAsString(JsonParser jacksonParser) throws Exception {
  Name instance = new Name();
  String fieldName;
  if (jacksonParser.getCurrentToken() == null) {
    jacksonParser.nextToken();
  }
  if (jacksonParser.getCurrentToken() != JsonToken.START_OBJECT) {
    jacksonParser.skipChildren();
    return instance;
  }
  while (jacksonParser.nextToken() != JsonToken.END_OBJECT) {
    fieldName = jacksonParser.getCurrentName();
    jacksonParser.nextToken();

    // Parse fields:
    switch (fieldName) {
        case "common":
          // field common (mapped with "common")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.common=jacksonParser.getText();
          }
        break;
        case "official":
          // field official (mapped with "official")
          if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) {
            instance.official=jacksonParser.getText();
          }
        break;
        case "native":
          // field _native (mapped with "native")
          if (jacksonParser.currentToken()==JsonToken.START_OBJECT || jacksonParser.currentToken()==JsonToken.VALUE_STRING) {
            instance._native=nativeBindMap.parseOnJacksonAsString(jacksonParser);
          }
        break;
        default:
          jacksonParser.skipChildren();
        break;}
  }
  return instance;
}