List of usage examples for com.fasterxml.jackson.core JsonParser getText
public abstract String getText() throws IOException, JsonParseException;
From source file:org.agorava.twitter.jackson.TimelineDateDeserializer.java
@Override public Date deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { try {/* ww w. j a v a2 s.c o m*/ return new SimpleDateFormat(TIMELINE_DATE_FORMAT, Locale.ENGLISH).parse(jp.getText()); } catch (ParseException e) { return null; } }
From source file:com.cedarsoft.serialization.serializers.jackson.HashValueSerializer.java
@Nonnull @Override/* ww w . j a v a 2 s . com*/ public Hash deserialize(@Nonnull JsonParser deserializeFrom, @Nonnull Version formatVersion) throws VersionException, IOException, JsonProcessingException { String hashAsString = deserializeFrom.getText(); return Hash.fromHex(algorithm, hashAsString); }
From source file:com.illumina.basespace.util.DateDeserializer.java
@Override public Date deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException { // /Date(2012-05-01T17:37:53.0000000)/ try {//from w w w . j ava2 s .c om return dateFormat.parse(parser.getText()); } catch (Throwable t) { logger.log(Level.SEVERE, "Error deserializing date from JSON object", t); return null; } }
From source file:net.landora.justintv.wrapper.JustinDateDeserializer.java
@Override public Calendar deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss zzz"); String date = jp.getText(); try {// ww w . j a v a 2 s . c o m Date d = format.parse(date); Calendar c = Calendar.getInstance(); c.setTime(d); return c; } catch (ParseException e) { throw new RuntimeException(e); } }
From source file:org.hyperledger.jackson.MasterPrivateKeyDeserializer.java
@Override public MasterPrivateKey deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonToken t = jp.getCurrentToken();//from w ww . j a va 2s. c o m if (t == JsonToken.VALUE_STRING) { try { String keyString = jp.getText().trim(); if (keyString.length() == 0) { return null; } return MasterPrivateKey.parse(keyString); } catch (HyperLedgerException e) { throw JsonMappingException.from(jp, "Error deserializing extended key", e); } } throw ctxt.mappingException(handledType()); }
From source file:org.hyperledger.jackson.MasterPublicKeyDeserializer.java
@Override public MasterPublicKey deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonToken t = jp.getCurrentToken();/* www .j a v a 2 s . co m*/ if (t == JsonToken.VALUE_STRING) { try { String keyString = jp.getText().trim(); if (keyString.length() == 0) { return null; } return MasterPublicKey.parse(keyString); } catch (HyperLedgerException e) { throw JsonMappingException.from(jp, "Error deserializing extended key", e); } } throw ctxt.mappingException(handledType()); }
From source file:org.hyperledger.jackson.AddressDeserializer.java
@Override public UIAddress deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonToken t = jp.getCurrentToken();// w w w . j ava 2 s.c om if (t == JsonToken.VALUE_STRING) { try { String satoshiStyle = jp.getText().trim(); if (satoshiStyle.length() == 0) { return null; } return UIAddress.fromSatoshiStyle(satoshiStyle); } catch (HyperLedgerException e) { throw JsonMappingException.from(jp, "Error deserializing address", e); } } throw ctxt.mappingException(handledType()); }
From source file:com.inversoft.json.LocaleDeserializer.java
@Override public Locale deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonToken t = jp.getCurrentToken();//from ww w.jav a 2 s. co m if (t == JsonToken.VALUE_STRING) { String str = jp.getText().trim(); if (str.length() == 0) { return null; } return toLocale(str); } throw ctxt.mappingException(handledType()); }
From source file:de.terrestris.shogun.deserializer.GeometryDeserializer.java
/** * Overwrite the deserializer for WKT geometry strings *//*from w ww .ja va 2 s . com*/ @Override public Geometry deserialize(JsonParser jsonParser, DeserializationContext context) throws JsonProcessingException { Geometry geom = null; try { geom = new WKTReader().read(jsonParser.getText()); if (geom != null) { //TODO: set the SRID dynamically geom.setSRID(900913); } } catch (Exception e) { e.printStackTrace(); return null; } return geom; }
From source file:fi.hsl.parkandride.core.domain.StrictIsoDateTimeDeserializer.java
@Override public DateTime deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { JsonToken token = jp.getCurrentToken(); if (token == JsonToken.VALUE_STRING) { String str = jp.getText().trim(); if (!isValid(str)) { throw ctxt.mappingException("expected ISO 8601 date time with timezone, " + "for example \"" + DateTime.now() + "\", but got \"" + str + "\""); }// ww w.j a v a2 s . com return (DateTime) dateTimeDeserializer.deserialize(jp, ctxt); } throw ctxt.mappingException(dateTimeDeserializer.handledType(), token); }