Java Code Examples for com.fasterxml.jackson.core.JsonParser#nextValue()
The following examples show how to use
com.fasterxml.jackson.core.JsonParser#nextValue() .
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: JacksonStreamTest.java From java-client-api with Apache License 2.0 | 6 votes |
private OrderItem getOrderItem(JsonParser parser) throws JsonParseException, IOException { OrderItem item = new OrderItem(); if ( parser.getCurrentToken() != JsonToken.START_OBJECT ) { throw new IllegalStateException("nextValue should have been START_OBJECT but is:[" + parser.getCurrentToken() + "]"); } while ( parser.nextValue() != null ) { if ( "productId".equals(parser.getCurrentName()) ) { item.setProductId( parser.getText() ); } else if ( "quantity".equals(parser.getCurrentName()) ) { item.setQuantity( parser.getIntValue() ); } else if ( "itemCostUSD".equals(parser.getCurrentName()) ) { item.setItemCostUSD( parser.getFloatValue() ); } if ( parser.getCurrentToken() == JsonToken.END_OBJECT ) { return item; } } return null; }
Example 2
Source File: BindBeanSharedPreferences.java From kripton with Apache License 2.0 | 6 votes |
/** * for attribute valueByteArray parsing */ protected byte[] parseValueByteArray(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(); byte[] result=null; if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { result=jacksonParser.getBinaryValue(); } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 3
Source File: CharDaoImpl.java From kripton with Apache License 2.0 | 5 votes |
/** * for param parser2 parsing */ private Character[] parser2(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(); Character[] 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.asCharacterArray(collection); } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 4
Source File: Bean2Table.java From kripton with Apache License 2.0 | 5 votes |
/** * 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 5
Source File: CharBeanTable.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute value2 parsing */ public static LinkedList<Character> parseValue2(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(); 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 6
Source File: BindBean2SharedPreferences.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueIntegerSet parsing */ protected LinkedHashSet<Integer> parseValueIntegerSet(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(); LinkedHashSet<Integer> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { LinkedHashSet<Integer> collection=new LinkedHashSet<>(); Integer item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getIntValue(); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 7
Source File: BindBeanSharedPreferences.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueShortSet parsing */ protected HashSet<Short> parseValueShortSet(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<Short> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashSet<Short> collection=new HashSet<>(); Short item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getShortValue(); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 8
Source File: CharDaoImpl.java From kripton with Apache License 2.0 | 5 votes |
/** * for param parser1 parsing */ private char[] parser1(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 9
Source File: BindBean64SharedPreferences.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueTimeList parsing */ protected List<Time> parseValueTimeList(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(); List<Time> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Time> collection=new ArrayList<>(); Time item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=SQLTimeUtils.read(jacksonParser.getText()); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 10
Source File: BeanDaoImpl.java From kripton with Apache License 2.0 | 5 votes |
/** * for param parser2 parsing */ private HashMap<EnumType, Byte> parser2(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(); HashMap<EnumType, Byte> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashMap<EnumType, Byte> collection=new HashMap<>(); EnumType key=null; Byte value=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { jacksonParser.nextValue(); { String tempEnum=jacksonParser.getText(); key=StringUtils.hasText(tempEnum)?EnumType.valueOf(tempEnum):null; } jacksonParser.nextValue(); if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { value=jacksonParser.getByteValue(); } collection.put(key, value); key=null; value=null; jacksonParser.nextToken(); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 11
Source File: BindBeanSharedPreferences.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueLongTypeArray parsing */ protected long[] parseValueLongTypeArray(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(); long[] result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Long> collection=new ArrayList<>(); Long item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getLongValue(); } collection.add(item); } result=CollectionUtils.asLongTypeArray(collection); } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 12
Source File: BindBean2SharedPreferences.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueEnumTypeSet parsing */ protected HashSet<EnumType> parseValueEnumTypeSet(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<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 13
Source File: FloatBeanTable.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute value2 parsing */ public static LinkedList<Float> parseValue2(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(); LinkedList<Float> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { LinkedList<Float> collection=new LinkedList<>(); Float item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getFloatValue(); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 14
Source File: LongBeanTable.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute value parsing */ public static long[] 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(); long[] result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Long> collection=new ArrayList<>(); Long item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getLongValue(); } collection.add(item); } result=CollectionUtils.asLongTypeArray(collection); } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 15
Source File: CharDaoImpl.java From kripton with Apache License 2.0 | 5 votes |
/** * for param parser2 parsing */ private Character[] parser2(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(); Character[] 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.asCharacterArray(collection); } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 16
Source File: ShortBeanTable.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute value parsing */ public static List<Short> 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<Short> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Short> collection=new ArrayList<>(); Short item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=jacksonParser.getShortValue(); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 17
Source File: Bean84ATable.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute columnMapIntegerString parsing */ public static Map<Integer, String> parseColumnMapIntegerString(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(); Map<Integer, String> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashMap<Integer, String> collection=new HashMap<>(); Integer key=null; String value=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { jacksonParser.nextValue(); key=jacksonParser.getIntValue(); jacksonParser.nextValue(); if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { value=jacksonParser.getText(); } collection.put(key, value); key=null; value=null; jacksonParser.nextToken(); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 18
Source File: BindBeanSharedPreferences.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueTimeList parsing */ protected List<Time> parseValueTimeList(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(); List<Time> result=null; if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<Time> collection=new ArrayList<>(); Time item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=SQLTimeUtils.read(jacksonParser.getText()); } collection.add(item); } result=collection; } return result; } catch(Exception e) { e.printStackTrace(); throw(new KriptonRuntimeException(e.getMessage())); } }
Example 19
Source File: Bean64Table.java From kripton with Apache License 2.0 | 5 votes |
/** * for attribute valueCharList parsing */ public static LinkedList<Character> parseValueCharList(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(); 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 20
Source File: Bean81RBindMap.java From kripton with Apache License 2.0 | 4 votes |
/** * parse with jackson */ @Override public Bean81R parseOnJackson(JsonParser jacksonParser) throws Exception { Bean81R instance = new Bean81R(); 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 "valueByteArray": // field valueByteArray (mapped with "valueByteArray") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.valueByteArray=jacksonParser.getBinaryValue(); } break; case "id": // field id (mapped with "id") instance.id=jacksonParser.getLongValue(); break; case "valueMapStringInteger": // field valueMapStringInteger (mapped with "valueMapStringInteger") if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { HashMap<String, Integer> collection=new HashMap<>(); String key=null; Integer value=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { jacksonParser.nextValue(); key=jacksonParser.getText(); jacksonParser.nextValue(); if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { value=jacksonParser.getIntValue(); } collection.put(key, value); key=null; value=null; jacksonParser.nextToken(); } instance.valueMapStringInteger=collection; } break; case "valueInteger": // field valueInteger (mapped with "valueInteger") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.valueInteger=jacksonParser.getIntValue(); } break; default: jacksonParser.skipChildren(); break;} } return instance; }