org.codehaus.jackson.map.DeserializationContext Java Examples
The following examples show how to use
org.codehaus.jackson.map.DeserializationContext.
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: CustomJsonDateDeserializer.java From jeecg with Apache License 2.0 | 6 votes |
@Override public Date deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { String text = jp.getText(); if (StringUtils.hasText(text)) { try { if (text.indexOf(":") == -1 && text.length() == 10) { return this.dateFormat.parse(text); } else if (text.indexOf(":") > 0 && text.length() == 19) { return this.datetimeFormat.parse(text); } else { throw new IllegalArgumentException("Could not parse date, date format is error "); } } catch (ParseException ex) { IllegalArgumentException iae = new IllegalArgumentException("Could not parse date: " + ex.getMessage()); iae.initCause(ex); throw iae; } } else { return null; } }
Example #2
Source File: StateDeserializer.java From big-c with Apache License 2.0 | 6 votes |
@Override public StatePair deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException { ObjectMapper mapper = (ObjectMapper) parser.getCodec(); // set the state-pair object tree ObjectNode statePairObject = (ObjectNode) mapper.readTree(parser); Class<?> stateClass = null; try { stateClass = Class.forName(statePairObject.get("className").getTextValue().trim()); } catch (ClassNotFoundException cnfe) { throw new RuntimeException("Invalid classname!", cnfe); } String stateJsonString = statePairObject.get("state").toString(); State state = (State) mapper.readValue(stateJsonString, stateClass); return new StatePair(state); }
Example #3
Source File: BackportedJacksonMappingIterator.java From elasticsearch-hadoop with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") protected BackportedJacksonMappingIterator(JavaType type, JsonParser jp, DeserializationContext ctxt, JsonDeserializer<?> deser) { _type = type; _parser = jp; _context = ctxt; _deserializer = (JsonDeserializer<T>) deser; /* One more thing: if we are at START_ARRAY (but NOT root-level * one!), advance to next token (to allow matching END_ARRAY) */ if (jp != null && jp.getCurrentToken() == JsonToken.START_ARRAY) { JsonStreamContext sc = jp.getParsingContext(); // safest way to skip current token is to clear it (so we'll advance soon) if (!sc.inRoot()) { jp.clearCurrentToken(); } } }
Example #4
Source File: ClientObjectMapper.java From hraven with Apache License 2.0 | 6 votes |
@Override public CounterMap deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { CounterMap counterMap = new CounterMap(); JsonToken token; while ((token = jsonParser.nextToken()) != JsonToken.END_OBJECT) { assertToken(token, JsonToken.FIELD_NAME); String group = jsonParser.getCurrentName(); assertToken(jsonParser.nextToken(), JsonToken.START_OBJECT); while ((token = jsonParser.nextToken()) != JsonToken.END_OBJECT) { if (token != JsonToken.VALUE_NUMBER_INT) { continue; // all deserialized values are ints } Counter counter = new Counter(group, jsonParser.getCurrentName(), jsonParser.getLongValue()); counterMap.add(counter); } } return counterMap; }
Example #5
Source File: JsonCreateWebServer.java From jwala with Apache License 2.0 | 6 votes |
@Override public JsonCreateWebServer deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { final ObjectCodec obj = jp.getCodec(); final JsonNode node = obj.readTree(jp).get(0); final JsonNode apacheHttpdMediaId = node.get("apacheHttpdMediaId"); final JsonCreateWebServer jcws = new JsonCreateWebServer(node.get("webserverName").getTextValue(), node.get("hostName").getTextValue(), node.get("portNumber").asText(), node.get("httpsPort").asText(), deserializeGroupIdentifiers(node), node.get("statusPath").getTextValue(), apacheHttpdMediaId == null ? null : apacheHttpdMediaId.asText()); return jcws; }
Example #6
Source File: JsonUpdateWebServer.java From jwala with Apache License 2.0 | 6 votes |
@Override public JsonUpdateWebServer deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { final ObjectCodec obj = jp.getCodec(); final JsonNode node = obj.readTree(jp).get(0); final Set<String> groupIds = deserializeGroupIdentifiers(node); return new JsonUpdateWebServer(node.get("webserverId").getValueAsText(), node.get("webserverName").getTextValue(), node.get("hostName").getTextValue(), node.get("portNumber").getValueAsText(), node.get("httpsPort").getValueAsText(), groupIds, node.get("statusPath").getTextValue(), node.get("apacheHttpdMediaId").getTextValue()); }
Example #7
Source File: GenericEntityDeserializer.java From secure-data-service with Apache License 2.0 | 6 votes |
@Override public GenericEntity deserialize(JsonParser parser, DeserializationContext context) throws IOException { ObjectMapper mapper = (ObjectMapper) parser.getCodec(); ObjectNode root = (ObjectNode) mapper.readTree(parser); String entityType = null; if (root.has(ENTITY_TYPE_KEY)) { entityType = root.get(ENTITY_TYPE_KEY).getTextValue(); root.remove(ENTITY_TYPE_KEY); } Map<String, Object> data = processObject(root); if (entityType != null) { return new GenericEntity(entityType, data); } else { return new GenericEntity("Generic", data); } }
Example #8
Source File: StateDeserializer.java From hadoop with Apache License 2.0 | 6 votes |
@Override public StatePair deserialize(JsonParser parser, DeserializationContext context) throws IOException, JsonProcessingException { ObjectMapper mapper = (ObjectMapper) parser.getCodec(); // set the state-pair object tree ObjectNode statePairObject = (ObjectNode) mapper.readTree(parser); Class<?> stateClass = null; try { stateClass = Class.forName(statePairObject.get("className").getTextValue().trim()); } catch (ClassNotFoundException cnfe) { throw new RuntimeException("Invalid classname!", cnfe); } String stateJsonString = statePairObject.get("state").toString(); State state = (State) mapper.readValue(stateJsonString, stateClass); return new StatePair(state); }
Example #9
Source File: JsonDateDeSerializer.java From AIDR with GNU Affero General Public License v3.0 | 5 votes |
@Override public Date deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { String date = jp.getText(); if(date!= null && !date.equals("")){ try { return dateFormat.parse(date); } catch (ParseException e) { logger.error("ParfseException for the date:"+date,e); throw new RuntimeException(e); } } return null; }
Example #10
Source File: JsonDateDeSerializer.java From AIDR with GNU Affero General Public License v3.0 | 5 votes |
@Override public Date deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { String date = jp.getText(); if(date!= null && !date.equals("")){ try { return dateFormat.parse(date); } catch (ParseException e) { throw new RuntimeException(e); } } return null; }
Example #11
Source File: LinkDeserializer.java From secure-data-service with Apache License 2.0 | 5 votes |
@Override public Link deserialize(JsonParser parser, DeserializationContext context) throws IOException { ObjectMapper mapper = (ObjectMapper) parser.getCodec(); ObjectNode root = (ObjectNode) mapper.readTree(parser); JsonNode relNode = root.get("rel"); JsonNode hrefNode = root.get("href"); return new BasicLink(relNode.asText(), new URL(hrefNode.asText())); }
Example #12
Source File: JsonUnknownPropertyHandler.java From spring-data-simpledb with MIT License | 5 votes |
@Override public boolean handleUnknownProperty(DeserializationContext ctxt, JsonDeserializer<?> deserializer, Object beanOrClass, String propertyName) throws IOException { JsonParser jsonParser = ctxt.getParser(); LOG.warn("Unknown Json property: " + propertyName); jsonParser.skipChildren(); return true; }
Example #13
Source File: ClientObjectMapper.java From hraven with Apache License 2.0 | 5 votes |
@Override public Configuration deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { Configuration conf = new Configuration(); JsonToken token; while ((token = jsonParser.nextToken()) != JsonToken.END_OBJECT) { if (token != JsonToken.VALUE_STRING) { continue; } // all deserialized values are strings conf.set(jsonParser.getCurrentName(), jsonParser.getText()); } return conf; }
Example #14
Source File: RuleJsonDeserializer.java From urule with Apache License 2.0 | 5 votes |
@Override public List<Rule> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { ObjectCodec oc = jp.getCodec(); JsonNode jsonNode = oc.readTree(jp); Iterator<JsonNode> childrenNodesIter=jsonNode.getElements(); List<Rule> rules=new ArrayList<Rule>(); while(childrenNodesIter.hasNext()){ JsonNode childNode=childrenNodesIter.next(); rules.add(parseRule(jp,childNode)); } return rules; }
Example #15
Source File: CustomJsonDateDeserializer.java From demo-restWS-spring-jersey-jpa2-hibernate with MIT License | 5 votes |
@Override public Date deserialize(JsonParser jsonparser, DeserializationContext context) throws IOException, JsonProcessingException { SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy HH:mm"); String date = jsonparser.getText(); try { return format.parse(date); } catch (ParseException e) { throw new RuntimeException(e); } }
Example #16
Source File: CustomFieldDeSerializer.java From jira-rest-client with Apache License 2.0 | 5 votes |
@Override public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { logger.info("Deserialize..."); ObjectCodec oc = jp.getCodec(); JsonNode node = oc.readTree(jp); for (int i = 0; i < node.size(); i++) { JsonNode child = node.get(i); if (child == null) { logger.info(i + "th Child node is null"); continue; } //String if (child.isTextual()) { Iterator<String> it = child.getFieldNames(); while (it.hasNext()) { String field = it.next(); logger.info("in while loop " + field); if (field.startsWith("customfield")) { } } } } return null; }
Example #17
Source File: EventCodecUtil.java From scheduling with GNU Affero General Public License v3.0 | 5 votes |
@Override public EventNotification deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { EventNotification notification = new EventNotification(); ObjectMapper mapper = (ObjectMapper) jp.getCodec(); ObjectNode root = (ObjectNode) mapper.readTree(jp); String actionString = root.get("action").getTextValue(); notification.setAction(Action.valueOf(actionString)); JsonNode data = root.get("data"); switch (notification.getAction()) { case JOB_SUBMITTED: notification.setData(mapper.readValue(data, JobStateData.class)); break; case JOB_STATE_UPDATED: notification.setData(mapper.readValue(data, JobInfoData.class)); break; case JOB_FULL_DATA_UPDATED: notification.setData(mapper.readValue(data, JobStateData.class)); break; case TASK_STATE_UPDATED: notification.setData(mapper.readValue(data, TaskInfoData.class)); break; case USERS_UPDATED: notification.setData(mapper.readValue(data, SchedulerUserData.class)); break; default: break; } notification.setSchedulerEvent(root.get("schedulerEvent").asText()); return notification; }
Example #18
Source File: SamzaObjectMapper.java From samza with Apache License 2.0 | 5 votes |
@Override public SystemStreamPartition deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); String system = node.get("system").getTextValue(); String stream = node.get("stream").getTextValue(); Partition partition = new Partition(node.get("partition").getIntValue()); return new SystemStreamPartition(system, stream, partition); }
Example #19
Source File: SamzaObjectMapper.java From samza with Apache License 2.0 | 5 votes |
@Override public Object deserializeKey(String sspString, DeserializationContext ctxt) throws IOException { int idx = sspString.indexOf('.'); int lastIdx = sspString.lastIndexOf('.'); if (idx < 0 || lastIdx < 0) { throw new IllegalArgumentException("System stream partition expected in format 'system.stream.partition"); } return new SystemStreamPartition( new SystemStream(sspString.substring(0, idx), sspString.substring(idx + 1, lastIdx)), new Partition(Integer.parseInt(sspString.substring(lastIdx + 1)))); }
Example #20
Source File: SamzaObjectMapper.java From samza with Apache License 2.0 | 5 votes |
@Override public TaskMode deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); if (node == null || node.getTextValue().equals("")) { return TaskMode.Active; } else { return TaskMode.valueOf(node.getTextValue()); } }
Example #21
Source File: SamzaObjectMapper.java From samza with Apache License 2.0 | 5 votes |
@Override public Config deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); return new MapConfig(OBJECT_MAPPER.<Map<String, String>>readValue(node, new TypeReference<Map<String, String>>() { })); }
Example #22
Source File: Directive.java From dcs-sdk-java with Apache License 2.0 | 5 votes |
@Override public Directive deserialize(JsonParser jp, DeserializationContext ctx) throws IOException { ObjectReader reader = ObjectMapperUtil.instance().getObjectReader(); ObjectNode obj = (ObjectNode) reader.readTree(jp); Iterator<Map.Entry<String, JsonNode>> elementsIterator = obj.getFields(); String rawMessage = obj.toString(); DialogRequestIdHeader header = null; JsonNode payloadNode = null; ObjectReader headerReader = ObjectMapperUtil.instance().getObjectReader(DialogRequestIdHeader.class); while (elementsIterator.hasNext()) { Map.Entry<String, JsonNode> element = elementsIterator.next(); if (element.getKey().equals("header")) { header = headerReader.readValue(element.getValue()); } if (element.getKey().equals("payload")) { payloadNode = element.getValue(); } } if (header == null) { throw ctx.mappingException("Missing header"); } if (payloadNode == null) { throw ctx.mappingException("Missing payload"); } return createDirective(header, payloadNode, rawMessage); }
Example #23
Source File: JsonControlJvm.java From jwala with Apache License 2.0 | 5 votes |
@Override public JsonControlJvm deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { final ObjectCodec obj = jp.getCodec(); final JsonNode rootNode = obj.readTree(jp); final JsonNode operation = rootNode.get("controlOperation"); return new JsonControlJvm(operation.getTextValue()); }
Example #24
Source File: JsonUpdateGroup.java From jwala with Apache License 2.0 | 5 votes |
@Override public JsonUpdateGroup deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { final ObjectCodec obj = jp.getCodec(); final JsonNode node = obj.readTree(jp); return new JsonUpdateGroup(node.get("id").getTextValue(), node.get("name").getTextValue()); }
Example #25
Source File: ContainerPlacementMessageObjectMapper.java From samza with Apache License 2.0 | 5 votes |
@Override public ContainerPlacementMessage deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); String subType = node.get("subType").getTextValue(); String deploymentId = node.get("deploymentId").getTextValue(); String processorId = node.get("processorId").getTextValue(); String destinationHost = node.get("destinationHost").getTextValue(); long timestamp = node.get("timestamp").getLongValue(); Duration requestExpiry = node.get("requestExpiry") == null ? null : Duration.ofMillis(node.get("requestExpiry").getLongValue()); ContainerPlacementMessage.StatusCode statusCode = null; UUID uuid = UUID.fromString(node.get("uuid").getTextValue()); for (ContainerPlacementMessage.StatusCode code : ContainerPlacementMessage.StatusCode.values()) { if (code.name().equals(node.get("statusCode").getTextValue())) { statusCode = code; } } ContainerPlacementMessage message = null; if (subType.equals(ContainerPlacementRequestMessage.class.getSimpleName())) { message = new ContainerPlacementRequestMessage(uuid, deploymentId, processorId, destinationHost, requestExpiry, timestamp); } else if (subType.equals(ContainerPlacementResponseMessage.class.getSimpleName())) { String responseMessage = node.get("responseMessage").getTextValue(); message = new ContainerPlacementResponseMessage(uuid, deploymentId, processorId, destinationHost, requestExpiry, statusCode, responseMessage, timestamp); } return message; }
Example #26
Source File: JsonJvms.java From jwala with Apache License 2.0 | 5 votes |
@Override public JsonJvms deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { final ObjectCodec obj = jp.getCodec(); final JsonNode rootNode = obj.readTree(jp); final Set<String> rawJvmIds = deserializeJvmIdentifiers(rootNode); return new JsonJvms(rawJvmIds); }
Example #27
Source File: JsonControlGroup.java From jwala with Apache License 2.0 | 5 votes |
@Override public JsonControlGroup deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { final ObjectCodec obj = jp.getCodec(); final JsonNode rootNode = obj.readTree(jp); final JsonNode operation = rootNode.get("controlOperation"); return new JsonControlGroup(operation.getTextValue()); }
Example #28
Source File: JsonControlWebServer.java From jwala with Apache License 2.0 | 5 votes |
@Override public JsonControlWebServer deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException { final ObjectCodec obj = jp.getCodec(); final JsonNode rootNode = obj.readTree(jp); final JsonNode operation = rootNode.get("controlOperation"); return new JsonControlWebServer(operation.getTextValue()); }
Example #29
Source File: PasswordDeserializer.java From jwala with Apache License 2.0 | 5 votes |
@Override public String deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException { if (StringUtils.isNotEmpty(jsonParser.getText())) { return new DecryptPassword().encrypt(jsonParser.getText()); } return StringUtils.EMPTY; }
Example #30
Source File: BackportedObjectReader.java From elasticsearch-hadoop with Apache License 2.0 | 4 votes |
public <T> BackportedJacksonMappingIterator<T> readValues(JsonParser jp) throws IOException, JsonProcessingException { DeserializationContext ctxt = _createDeserializationContext(jp, _config); return new BackportedJacksonMappingIterator<T>(_valueType, jp, ctxt, _findRootDeserializer(_config, _valueType)); }