Java Code Examples for com.fasterxml.jackson.core.JsonParser#getCurrentName()
The following examples show how to use
com.fasterxml.jackson.core.JsonParser#getCurrentName() .
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: PropertyExtractingEventReader.java From fahrschein with Apache License 2.0 | 6 votes |
@Override public List<T> read(JsonParser jsonParser) throws IOException { expectToken(jsonParser.nextToken(), JsonToken.START_ARRAY); final List<T> result = new ArrayList<>(); for (JsonToken token = jsonParser.nextToken(); token != JsonToken.END_ARRAY; token = jsonParser.nextToken()) { expectToken(token, JsonToken.START_OBJECT); for (token = jsonParser.nextToken(); token != JsonToken.END_OBJECT; token = jsonParser.nextToken()) { expectToken(token, JsonToken.FIELD_NAME); final String topLevelProperty = jsonParser.getCurrentName(); jsonParser.nextToken(); if (propertyName.equals(topLevelProperty)) { final T value = getValue(jsonParser); result.add(value); } else { jsonParser.skipChildren(); } } } return result; }
Example 2
Source File: NodeDeserializer.java From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 | 6 votes |
protected ObjectNode deserializeObjectNode(JsonParser p, DeserializationContext context, JsonLocation startLocation) throws IllegalArgumentException, IOException { final Model model = (Model) context.getAttribute(ATTRIBUTE_MODEL); final AbstractNode parent = (AbstractNode) context.getAttribute(ATTRIBUTE_PARENT); final JsonPointer ptr = (JsonPointer) context.getAttribute(ATTRIBUTE_POINTER); final ObjectNode node = model.objectNode(parent, ptr); node.setStartLocation(createLocation(startLocation)); while (p.nextToken() != JsonToken.END_OBJECT) { String name = p.getCurrentName(); JsonPointer pp = JsonPointer.compile(ptr.toString() + "/" + name.replaceAll("/", "~1")); context.setAttribute(ATTRIBUTE_PARENT, node); context.setAttribute(ATTRIBUTE_POINTER, pp); AbstractNode v = deserialize(p, context); v.setProperty(name); node.put(name, v); } node.setEndLocation(createLocation(p.getCurrentLocation())); return node; }
Example 3
Source File: DruidConnectionImpl.java From calcite with Apache License 2.0 | 6 votes |
private Long extractTimestampField(JsonParser parser) throws IOException { expect(parser, JsonToken.FIELD_NAME); if (!parser.getCurrentName().equals(DEFAULT_RESPONSE_TIMESTAMP_COLUMN)) { throw new RuntimeException("expected field " + DEFAULT_RESPONSE_TIMESTAMP_COLUMN + ", got " + parser.getCurrentName()); } parser.nextToken(); try { final Date parse; // synchronized block to avoid race condition synchronized (UTC_TIMESTAMP_FORMAT) { parse = UTC_TIMESTAMP_FORMAT.parse(parser.getText()); } return parse.getTime(); } catch (ParseException e) { // ignore bad value } return null; }
Example 4
Source File: Bean81IBindMap.java From kripton with Apache License 2.0 | 5 votes |
/** * parse with jackson */ @Override public Bean81I parseOnJackson(JsonParser jacksonParser) throws Exception { Bean81I instance = new Bean81I(); 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 "valueBigDecimal": // field valueBigDecimal (mapped with "valueBigDecimal") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.valueBigDecimal=BigDecimalUtils.read(jacksonParser.getText()); } break; case "id": // field id (mapped with "id") instance.id=jacksonParser.getLongValue(); break; case "valueBigInteger": // field valueBigInteger (mapped with "valueBigInteger") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.valueBigInteger=BigIntegerUtils.read(jacksonParser.getText()); } break; default: jacksonParser.skipChildren(); break;} } return instance; }
Example 5
Source File: Bean80ABindMap.java From kripton with Apache License 2.0 | 5 votes |
/** * parse with jackson */ @Override public Bean80A parseOnJacksonAsString(JsonParser jacksonParser) throws Exception { Bean80A instance = new Bean80A(); 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 "valueBean": // field valueBean (mapped with "valueBean") if (jacksonParser.currentToken()==JsonToken.START_OBJECT || jacksonParser.currentToken()==JsonToken.VALUE_STRING) { instance.valueBean=bean80ABindMap.parseOnJacksonAsString(jacksonParser); } break; case "valueString": // field valueString (mapped with "valueString") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.valueString=jacksonParser.getText(); } break; default: jacksonParser.skipChildren(); break;} } return instance; }
Example 6
Source File: BeanA_3BindMap.java From kripton with Apache License 2.0 | 5 votes |
/** * parse with jackson */ @Override public BeanA_3 parseOnJackson(JsonParser jacksonParser) throws Exception { BeanA_3 instance = new BeanA_3(); 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.getLongValue(); 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 7
Source File: Bean70ABindMap.java From kripton with Apache License 2.0 | 5 votes |
/** * parse with jackson */ @Override public Bean70A parseOnJackson(JsonParser jacksonParser) throws Exception { Bean70A instance = new Bean70A(); 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 "valueBean": // field valueBean (mapped with "valueBean") if (jacksonParser.currentToken()==JsonToken.START_OBJECT) { instance.valueBean=bean70ABindMap.parseOnJackson(jacksonParser); } break; case "valueString": // field valueString (mapped with "valueString") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.valueString=jacksonParser.getText(); } break; default: jacksonParser.skipChildren(); break;} } return instance; }
Example 8
Source File: Bean205BindMap.java From kripton with Apache License 2.0 | 5 votes |
/** * parse with jackson */ @Override public Bean205 parseOnJackson(JsonParser jacksonParser) throws Exception { Bean205 instance = new Bean205(); 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.setId(jacksonParser.getLongValue()); 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 9
Source File: SeminarBindMap.java From kripton with Apache License 2.0 | 5 votes |
/** * parse with jackson */ @Override public Seminar parseOnJackson(JsonParser jacksonParser) throws Exception { Seminar instance = new Seminar(); 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.getLongValue(); break; case "location": // field location (mapped with "location") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.location=jacksonParser.getText(); } 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 10
Source File: PersonBindMap.java From kripton with Apache License 2.0 | 5 votes |
/** * 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 "age": // field age (mapped with "age") instance.age=PrimitiveUtils.readInteger(jacksonParser.getText(), 0); break; 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 11
Source File: NativeBindMap.java From kripton with Apache License 2.0 | 5 votes |
/** * parse with jackson */ @Override public Native parseOnJackson(JsonParser jacksonParser) throws Exception { Native instance = new Native(); 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 "nld": // field nld (mapped with "nld") if (jacksonParser.currentToken()==JsonToken.START_OBJECT) { instance.nld=nldBindMap.parseOnJackson(jacksonParser); } break; case "pap": // field pap (mapped with "pap") if (jacksonParser.currentToken()==JsonToken.START_OBJECT) { instance.pap=papBindMap.parseOnJackson(jacksonParser); } break; default: jacksonParser.skipChildren(); break;} } return instance; }
Example 12
Source File: Bean81HBindMap.java From kripton with Apache License 2.0 | 5 votes |
/** * parse with jackson */ @Override public Bean81H parseOnJacksonAsString(JsonParser jacksonParser) throws Exception { Bean81H instance = new Bean81H(); 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 "valueBigInteger": // field valueBigInteger (mapped with "valueBigInteger") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.valueBigInteger=BigIntegerUtils.read(jacksonParser.getText()); } break; case "id": // field id (mapped with "id") instance.id=PrimitiveUtils.readLong(jacksonParser.getText(), 0L); break; case "valueBigDecimal": // field valueBigDecimal (mapped with "valueBigDecimal") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.valueBigDecimal=BigDecimalUtils.read(jacksonParser.getText()); } break; default: jacksonParser.skipChildren(); break;} } return instance; }
Example 13
Source File: BooleanDeserializer.java From govpay with GNU General Public License v3.0 | 5 votes |
@Override public Boolean deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); if(node instanceof BooleanNode) { BooleanNode bNode = (BooleanNode) node; return bNode.booleanValue(); } throw new JsonParseException(jsonParser, "il field " + jsonParser.getCurrentName() + " non e' di tipo " + Boolean.class.getName() + "."); }
Example 14
Source File: StackTraceElementDeserializer.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public StackTraceElement deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonToken t = p.getCurrentToken(); // Must get an Object if (t == JsonToken.START_OBJECT) { String className = "", methodName = "", fileName = ""; // Java 9 adds couple more things String moduleName = null, moduleVersion = null; String classLoaderName = null; int lineNumber = -1; while ((t = p.nextValue()) != JsonToken.END_OBJECT) { String propName = p.getCurrentName(); // TODO: with Java 8, convert to switch if ("className".equals(propName)) { className = p.getText(); } else if ("classLoaderName".equals(propName)) { classLoaderName = p.getText(); } else if ("fileName".equals(propName)) { fileName = p.getText(); } else if ("lineNumber".equals(propName)) { if (t.isNumeric()) { lineNumber = p.getIntValue(); } else { lineNumber = _parseIntPrimitive(p, ctxt); } } else if ("methodName".equals(propName)) { methodName = p.getText(); } else if ("nativeMethod".equals(propName)) { // no setter, not passed via constructor: ignore } else if ("moduleName".equals(propName)) { moduleName = p.getText(); } else if ("moduleVersion".equals(propName)) { moduleVersion = p.getText(); } else if ("declaringClass".equals(propName) || "format".equals(propName)) { // 01-Nov-2017: [databind#1794] Not sure if we should but... let's prune it for now ; } else { handleUnknownProperty(p, ctxt, _valueClass, propName); } p.skipChildren(); // just in case we might get structured values } return constructValue(ctxt, className, methodName, fileName, lineNumber, moduleName, moduleVersion, classLoaderName); } else if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { p.nextToken(); final StackTraceElement value = deserialize(p, ctxt); if (p.nextToken() != JsonToken.END_ARRAY) { handleMissingEndArrayForSingle(p, ctxt); } return value; } return (StackTraceElement) ctxt.handleUnexpectedToken(_valueClass, p); }
Example 15
Source File: CommentBindMap.java From kripton with Apache License 2.0 | 4 votes |
/** * parse with jackson */ @Override public Comment parseOnJackson(JsonParser jacksonParser) throws Exception { Comment instance = new Comment(); 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 "body": // field body (mapped with "body") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.body=jacksonParser.getText(); } break; case "email": // field email (mapped with "email") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.email=jacksonParser.getText(); } break; case "id": // field id (mapped with "id") instance.id=jacksonParser.getLongValue(); break; case "name": // field name (mapped with "name") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.name=jacksonParser.getText(); } break; case "postId": // field postId (mapped with "postId") instance.postId=jacksonParser.getLongValue(); break; default: jacksonParser.skipChildren(); break;} } return instance; }
Example 16
Source File: JsonEntityParser.java From sailfish-core with Apache License 2.0 | 4 votes |
public static FailedAction parse(IDictionaryManager dictionaryManager, InputStream requestBody, boolean storeId) throws JsonParseException, IOException { JsonFactory factory = new JsonFactory(); JsonParser parser = factory.createParser(requestBody); FailedAction failedAction = new FailedAction(); checkToken(parser, JsonToken.START_OBJECT, parser.nextToken()); Map<String, String> rootFields = new HashMap<>(); Consumer<JsonParser> actualsPropertyParser = consumerWrapper(p -> { checkToken(p, JsonToken.START_ARRAY, p.nextToken()); p.nextToken(); do { checkToken(p, JsonToken.START_OBJECT, p.getCurrentToken()); Map<String, String> messageFields = new HashMap<>(); Message message = null; while (p.nextToken() != JsonToken.END_OBJECT) { if (!collectField(p, messageFields, JsonMessageConverter.JSON_MESSAGE)) { message = parseMessage(dictionaryManager, p, messageFields, true, storeId); } } boolean explanation = BooleanUtils.toBoolean(messageFields.get("problemExplanation")); long participantId = ObjectUtils.defaultIfNull(Long.parseLong(messageFields.get("id")), 0L); MessageParticipant messageParticipant = new MessageParticipant(explanation, message); if (storeId) { messageParticipant.setId(participantId); } if (messageFields.containsKey("timestamp")) { messageParticipant.setTimestamp(Long.parseLong(messageFields.get("timestamp"))); } failedAction.addParticipant(messageParticipant); } while (p.nextToken() != JsonToken.END_ARRAY); }); Map<String, Consumer<JsonParser>> beanPropertiesHandlers = new HashMap<>(); beanPropertiesHandlers.put("actuals", actualsPropertyParser); beanPropertiesHandlers.put("user", consumerWrapper(p -> { p.nextToken(); failedAction.setSubmitter(p.getValueAsString()); })); while (parser.nextToken() != JsonToken.END_OBJECT) { if (parser.getCurrentToken() == JsonToken.FIELD_NAME) { if (collectField(parser, rootFields, "expected", "actuals", "user")) continue; String currentName = parser.getCurrentName(); if ("expected".equals(currentName)) { //Special logic for handle properties before expected complex node failedAction.setExpectedMessage(parseMessage(dictionaryManager, parser, rootFields, false, storeId)); rootFields.forEach((k, v) -> { try { BeanUtils.setProperty(failedAction, k, v); } catch (Exception e) { throw new EPSCommonException(e); } }); } else { if (!beanPropertiesHandlers.containsKey(currentName)) { throw new JsonParseException("Unsupported root field " + currentName, parser.getCurrentLocation()); } beanPropertiesHandlers.get(currentName).accept(parser); } } else { throw new JsonParseException("Unsupported type " + parser.getCurrentToken(), parser.getCurrentLocation()); } } checkToken(parser, JsonToken.END_OBJECT, parser.getCurrentToken()); return failedAction; }
Example 17
Source File: NodeCalc.java From powsybl-core with Mozilla Public License 2.0 | 4 votes |
static NodeCalc parseJson(JsonParser parser, JsonToken token) throws IOException { Objects.requireNonNull(parser); Objects.requireNonNull(token); if (token == JsonToken.FIELD_NAME) { String fieldName = parser.getCurrentName(); switch (fieldName) { case IntegerNodeCalc.NAME: return IntegerNodeCalc.parseJson(parser); case FloatNodeCalc.NAME: return FloatNodeCalc.parseJson(parser); case DoubleNodeCalc.NAME: return DoubleNodeCalc.parseJson(parser); case BigDecimalNodeCalc.NAME: return BigDecimalNodeCalc.parseJson(parser); case BinaryOperation.NAME: return BinaryOperation.parseJson(parser); case UnaryOperation.NAME: return UnaryOperation.parseJson(parser); case MinNodeCalc.NAME: return MinNodeCalc.parseJson(parser); case MaxNodeCalc.NAME: return MaxNodeCalc.parseJson(parser); case TimeSeriesNameNodeCalc.NAME: return TimeSeriesNameNodeCalc.parseJson(parser); case TimeNodeCalc.NAME: return TimeNodeCalc.parseJson(parser); default: break; } } throw createUnexpectedToken(token); }
Example 18
Source File: TextureAnimationBindMap.java From kripton with Apache License 2.0 | 4 votes |
/** * parse with jackson */ @Override public TextureAnimation parseOnJackson(JsonParser jacksonParser) throws Exception { TextureAnimation instance = new TextureAnimation(); 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 "name": // field name (mapped with "name") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.setName(jacksonParser.getText()); } break; case "loop": // field loop (mapped with "loop") instance.setLoop(jacksonParser.getBooleanValue()); break; case "rate": // field rate (mapped with "rate") instance.setRate(jacksonParser.getFloatValue()); break; case "frames": // field frames (mapped with "frames") if (jacksonParser.currentToken()==JsonToken.START_ARRAY) { ArrayList<TextureKeyFrame> collection=new ArrayList<>(); TextureKeyFrame item=null; while (jacksonParser.nextToken() != JsonToken.END_ARRAY) { if (jacksonParser.currentToken()==JsonToken.VALUE_NULL) { item=null; } else { item=textureKeyFrameBindMap.parseOnJackson(jacksonParser); } collection.add(item); } instance.frames=collection; } break; default: jacksonParser.skipChildren(); break;} } return instance; }
Example 19
Source File: EntityBeanDeserializer.java From requery with Apache License 2.0 | 4 votes |
@Override public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) throws IOException { if (_nonStandardCreation || _needViewProcesing) { return super.deserializeFromObject(p, ctxt); } Object bean = null; if (p.hasTokenId(JsonTokenId.ID_FIELD_NAME)) { String propertyName = p.getCurrentName(); do { p.nextToken(); SettableBeanProperty property = _beanProperties.find(propertyName); if (property == null) { handleUnknownVanilla(p, ctxt, bean, propertyName); continue; } // lazily create the bean, the id property must be the first property if (bean == null) { if (propertyName.equals(_objectIdReader.propertyName.getSimpleName())) { // deserialize id Object id = property.deserialize(p, ctxt); ReadableObjectId objectId = ctxt.findObjectId(id, _objectIdReader.generator, _objectIdReader.resolver); bean = objectId == null ? null : objectId.resolve(); if (bean == null) { bean = _valueInstantiator.createUsingDefault(ctxt); property.set(bean, id); } } else { bean = _valueInstantiator.createUsingDefault(ctxt); } p.setCurrentValue(bean); } property.deserializeAndSet(p, ctxt, bean); } while ((propertyName = p.nextFieldName()) != null); } return bean; }
Example 20
Source File: Bean93BindMap.java From kripton with Apache License 2.0 | 4 votes |
/** * parse with jackson */ @Override public Bean93 parseOnJackson(JsonParser jacksonParser) throws Exception { Bean93 instance = new Bean93(); 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.getLongValue(); 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 "typeName": // field typeName (mapped with "typeName") if (jacksonParser.currentToken()!=JsonToken.VALUE_NULL) { instance.typeName=jacksonParser.getText(); } break; default: jacksonParser.skipChildren(); break;} } return instance; }