Java Code Examples for com.fasterxml.jackson.core.JsonParser#hasTokenId()
The following examples show how to use
com.fasterxml.jackson.core.JsonParser#hasTokenId() .
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: CustomLocalDateDeserializer.java From celerio-angular-quickstart with Apache License 2.0 | 5 votes |
public LocalDate deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException { if (parser.hasTokenId(JsonTokenId.ID_STRING)) { String date = parser.getText().trim(); if (date.isEmpty()) { return null; } return LocalDateTime.ofInstant(Instant.parse(date), ZoneOffset.UTC).toLocalDate(); } return null; }
Example 2
Source File: SanitizingJsonOutputStream.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Override public void copyCurrentStructure(JsonParser jp) throws IOException { if (jp.hasTokenId(ID_FIELD_NAME) && fields.contains(jp.getCurrentName())) { skip++; super.copyCurrentStructure(jp); skip--; } else { super.copyCurrentStructure(jp); } }
Example 3
Source File: LocalDateTimeDeserializer.java From bootique with Apache License 2.0 | 5 votes |
@Override public LocalDateTime deserialize(JsonParser parser, DeserializationContext context) throws IOException { if (parser.hasTokenId(JsonTokenId.ID_STRING)) { String string = parser.getText().trim(); if (string.length() == 0) { return null; } return LocalDateTime.parse(string, _formatter); } throw context.wrongTokenException(parser, JsonToken.START_ARRAY, "Expected array or string."); }
Example 4
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 5
Source File: CustomLocalDateTimeDeserializer.java From celerio-angular-quickstart with Apache License 2.0 | 3 votes |
public LocalDateTime deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException { if (parser.hasTokenId(JsonTokenId.ID_STRING)) { String date = parser.getText().trim(); if (date.isEmpty()) { return null; } return LocalDateTime.ofInstant(Instant.parse(date), ZoneOffset.UTC); } return null; }