Java Code Examples for org.codehaus.jackson.JsonParser#getCodec()
The following examples show how to use
org.codehaus.jackson.JsonParser#getCodec() .
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: AbstractJsonDeserializer.java From urule with Apache License 2.0 | 6 votes |
private void buildScoreRule(JsonParser jsonParser,JsonNode ruleNode,ScoreRule rule){ rule.setScoringBean(JsonUtils.getJsonValue(ruleNode, "scoringBean")); AssignTargetType assignTargetType=AssignTargetType.valueOf(JsonUtils.getJsonValue(ruleNode, "assignTargetType")); rule.setAssignTargetType(assignTargetType); rule.setVariableCategory(JsonUtils.getJsonValue(ruleNode, "variableCategory")); rule.setVariableName(JsonUtils.getJsonValue(ruleNode, "variableName")); rule.setVariableLabel(JsonUtils.getJsonValue(ruleNode, "variableLabel")); String datatypeStr=JsonUtils.getJsonValue(ruleNode, "datatype"); if(StringUtils.isNotBlank(datatypeStr)){ rule.setDatatype(Datatype.valueOf(datatypeStr)); } try{ JsonNode knowledgePackageWrapperNode=ruleNode.get("knowledgePackageWrapper"); ObjectMapper mapper = (ObjectMapper)jsonParser.getCodec(); KnowledgePackageWrapper wrapper=mapper.readValue(knowledgePackageWrapperNode, KnowledgePackageWrapper.class); wrapper.buildDeserialize(); rule.setKnowledgePackageWrapper(wrapper); }catch(Exception ex){ throw new RuleException(ex); } }
Example 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
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 12
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 13
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 14
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 15
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 16
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 17
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 18
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 19
Source File: SamzaObjectMapper.java From samza with Apache License 2.0 | 4 votes |
@Override public Partition deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); return new Partition(node.getIntValue()); }
Example 20
Source File: SamzaObjectMapper.java From samza with Apache License 2.0 | 4 votes |
@Override public TaskName deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException, JsonProcessingException { ObjectCodec oc = jsonParser.getCodec(); JsonNode node = oc.readTree(jsonParser); return new TaskName(node.getTextValue()); }