List of usage examples for com.fasterxml.jackson.core JsonParser getText
public abstract String getText() throws IOException, JsonParseException;
From source file:org.mycontroller.standalone.api.jaxrs.mixins.deserializers.UnitTypeDeserializer.java
@Override public UNIT_TYPE deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException { final String nodeType = parser.getText(); if (nodeType != null) { return UNIT_TYPE.fromString(nodeType); } else {/*from w w w .j a v a 2 s . c om*/ return null; } }
From source file:org.springframework.social.google.api.impl.ApiEnumDeserializer.java
@Override public T deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { String camelCase = jp.getText(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < camelCase.length(); i++) { char c = camelCase.charAt(i); if (Character.isUpperCase(c)) { sb.append('_').append(c); } else {/*from w w w . ja v a 2 s .c o m*/ sb.append(Character.toUpperCase(c)); } } @SuppressWarnings({ "rawtypes", "unchecked" }) T value = (T) Enum.valueOf((Class) type, sb.toString()); return value; }
From source file:com.pamarin.api.converter.JsonLocaleDeserializer.java
@Override public Locale deserialize(JsonParser jp, DeserializationContext dc) throws IOException, JsonProcessingException { String localeCode = jp.getText(); if (!hasText(localeCode)) { return null; }/*from w w w . ja va 2 s .c om*/ String[] split = StringUtils.split(localeCode, "_"); if (split.length != 2) { throw new IOException("not support locale, require language and country"); } if (!hasText(split[0])) { throw new IOException("not support locale, require language"); } if (!hasText(split[1])) { throw new IOException("not support locale, require country"); } return new Locale(split[0], split[1]); }
From source file:io.druid.jackson.CommaListJoinDeserializer.java
@Override public List<String> deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { return Arrays.asList(jsonParser.getText().split(",")); }
From source file:org.agorava.linkedin.jackson.UpdateTypeDeserializer.java
@Override public UpdateType deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { try {/*w ww . j a v a 2 s . co m*/ return UpdateType.valueOf(jp.getText().toUpperCase()); } catch (IllegalArgumentException e) { return UpdateType.UNKNOWN; } }
From source file:org.hawkular.alerts.rest.json.LinkDeserializer.java
@Override public Link deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { String tmp = jp.getText(); // { validate(jp, tmp, "{"); jp.nextToken(); // skip over { to the rel String rel = jp.getText();//from w ww . ja va 2 s . c o m validateText(jp, rel); jp.nextToken(); // skip over { tmp = jp.getText(); validate(jp, tmp, "{"); jp.nextToken(); // skip over "href" tmp = jp.getText(); validate(jp, tmp, "href"); jp.nextToken(); // skip to "http:// ... " String href = jp.getText(); validateText(jp, href); jp.nextToken(); // skip } tmp = jp.getText(); validate(jp, tmp, "}"); jp.nextToken(); // skip } tmp = jp.getText(); validate(jp, tmp, "}"); Link link = new Link(rel, href); return link; }
From source file:ru.gkpromtech.exhibition.utils.JsonDateDeserializer.java
@Override public Date deserialize(JsonParser jp, DeserializationContext ctx) throws IOException { // "2015-02-27T10:22:38.000Z" try {/* w w w. jav a2s . c o m*/ return new Date(Long.parseLong(jp.getText()) * 1000); } catch (Exception e) { e.printStackTrace(); } return null; }
From source file:com.wealdtech.jackson.modules.DateTimeDeserializer.java
@Override public DateTime deserialize(final JsonParser jp, final DeserializationContext deserializationContext) throws IOException { final String txt = jp.getText(); if (txt == null) { return null; }//w w w.j a v a 2 s . com return deserialize(txt); }
From source file:org.commonjava.maven.atlas.ident.jackson.ProjectRefDeserializer.java
@Override public T deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException, JsonProcessingException { return SerializerIdentityUtils.parse(jp.getText(), refCls); }
From source file:com.allogy.json.jackson.joda.ISODateTimeDeserializer.java
@Override public DateTime deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { String text = jsonParser.getText(); try {/*from ww w . ja v a 2 s. c o m*/ return dateTimeFormatter.parseDateTime(text); } catch (Throwable throwable) { throw new InvalidFormatException(throwable.getMessage(), text, String.class); } }