當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectCodec.readTree方法代碼示例

本文整理匯總了Java中com.fasterxml.jackson.core.ObjectCodec.readTree方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectCodec.readTree方法的具體用法?Java ObjectCodec.readTree怎麽用?Java ObjectCodec.readTree使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.fasterxml.jackson.core.ObjectCodec的用法示例。


在下文中一共展示了ObjectCodec.readTree方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public X509CertificateCredential deserialize(final JsonParser jp, 
                                             final DeserializationContext deserializationContext) 
        throws IOException {
    final ObjectCodec oc = jp.getCodec();
    final JsonNode node = oc.readTree(jp);

    final List<X509Certificate> certs = new ArrayList<>();
    node.findValues("certificates").forEach(n -> {
        final String cert = n.get(0).textValue();
        final byte[] data = EncodingUtils.decodeBase64(cert);
        certs.add(CertUtils.readCertificate(new InputStreamResource(new ByteArrayInputStream(data))));
    });
    final X509CertificateCredential c = new X509CertificateCredential(certs.toArray(new X509Certificate[] {}));
    return c;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:17,代碼來源:X509CertificateCredentialJsonDeserializer.java

示例2: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public Object deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
    throws IOException, JsonProcessingException {
  ObjectCodec oc = jsonParser.getCodec();
  JsonNode node = oc.readTree(jsonParser);
  if (node instanceof ArrayNode) {
    ArrayNode arrayNode = (ArrayNode) node;
    ArrayList<String> ret = new ArrayList<>();
    for (int i = 0; i < arrayNode.size(); i++) {
      ret.add(arrayNode.get(i).textValue());
    }
    return ret.toArray(new String[0]);
  } else {
    return new String[]{node.textValue()};
  }

}
 
開發者ID:pinterest,項目名稱:soundwave,代碼行數:18,代碼來源:StringArrayOrElementStringDeserializer.java

示例3: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public final Bijhoudingsautorisatie deserialize(final JsonParser jp, final DeserializationContext ctxt) throws IOException {
    final ObjectCodec oc = jp.getCodec();
    final JsonNode node = oc.readTree(jp);

    final Boolean indicatieModelautorisatie =
            JsonUtils.getAsBoolean(
                    node,
                    BijhoudingsautorisatieModule.INDICATIE_MODEL_AUTORISATIE,
                    BijhoudingsautorisatieModule.WAARDE_JA,
                    Boolean.TRUE,
                    Boolean.FALSE);
    final Bijhoudingsautorisatie bijhoudingsautorisatie = new Bijhoudingsautorisatie(indicatieModelautorisatie);

    bijhoudingsautorisatie.setId(JsonUtils.getAsInteger(node, BijhoudingsautorisatieModule.ID));
    bijhoudingsautorisatie.setNaam(JsonUtils.getAsString(node, BijhoudingsautorisatieModule.NAAM));
    bijhoudingsautorisatie.setDatumIngang(JsonUtils.getAsInteger(node, BijhoudingsautorisatieModule.DATUM_INGANG));
    bijhoudingsautorisatie.setDatumEinde(JsonUtils.getAsInteger(node, BijhoudingsautorisatieModule.DATUM_EINDE));
    bijhoudingsautorisatie.setIndicatieGeblokkeerd(
            JsonUtils.getAsBoolean(node, BijhoudingsautorisatieModule.INDICATIE_GEBLOKKEERD, BijhoudingsautorisatieModule.WAARDE_JA, Boolean.TRUE, null));

    return bijhoudingsautorisatie;
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:24,代碼來源:BijhoudingsautorisatieDeserializer.java

示例4: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public Room deserialize(JsonParser jp, DeserializationContext context) throws IOException,
        JsonProcessingException {

    ObjectCodec oc = jp.getCodec();
    JsonNode node = oc.readTree(jp);

    String roomId = node.get("id").asText();
    String name = node.get("name").asText();
    String topic = node.get("topic").get("value").asText();

    DateTime creationDate = new DateTime(node.get("created").asLong() * 1000L);
    String ownerUserId = node.get("creator").asText();
    boolean archived = node.get("is_archived").asBoolean();
    boolean privateRoom = roomId.startsWith("G");
    return new Room(roomId, name, topic, null, creationDate, ownerUserId, archived,
                    privateRoom, null, null);
}
 
開發者ID:OpenChatAlytics,項目名稱:OpenChatAlytics,代碼行數:19,代碼來源:RoomDeserializer.java

示例5: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public User deserialize(JsonParser jp, DeserializationContext context)
        throws IOException, JsonProcessingException {

    ObjectCodec oc = jp.getCodec();
    JsonNode node = oc.readTree(jp);

    String userId = node.get("id").asText();
    String mentionName = node.get("name").asText();
    boolean deleted = node.get("deleted").asBoolean();
    boolean groupAdmin = getAsBooleanOrFalse(node.get("is_admin"));
    String statusMessage = getAsTextOrNull(node.get("status"));
    String timezone = getAsTextOrNull(node.get("tz"));

    JsonNode profileNode = node.get("profile");
    String name = profileNode.get("real_name").asText();
    String title = getAsTextOrNull(profileNode.get("title"));
    String email = getAsTextOrNull(profileNode.get("email"));
    String photoUrl = profileNode.get("image_32").asText();

    return new User(userId, email, deleted, groupAdmin, false, name, mentionName, photoUrl,
                    null, null, null, statusMessage, timezone, title);
}
 
開發者ID:OpenChatAlytics,項目名稱:OpenChatAlytics,代碼行數:24,代碼來源:UserDeserializer.java

示例6: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public Room deserialize(JsonParser jp, DeserializationContext context) throws IOException,
        JsonProcessingException {

    ObjectCodec oc = jp.getCodec();
    JsonNode node = oc.readTree(jp);

    int roomId = node.get("room_id").asInt();
    String name = node.get("name").asText();
    String topic = node.get("topic").asText();

    DateTime lastActiveDate = new DateTime(node.get("last_active").asLong() * 1000L);
    DateTime creationDate = new DateTime(node.get("created").asLong() * 1000L);
    int ownerUserId = node.get("owner_user_id").asInt();
    boolean archived = node.get("is_archived").asBoolean();
    boolean privateRoom = node.get("is_private").asBoolean();
    String guestAccessURL = getAsTextOrNull(node.get("guest_access_url"));
    String xmppJid = node.get("xmpp_jid").asText();
    return new Room(String.valueOf(roomId), name, topic, lastActiveDate, creationDate,
                    String.valueOf(ownerUserId), archived, privateRoom, guestAccessURL,
                    xmppJid);
}
 
開發者ID:OpenChatAlytics,項目名稱:OpenChatAlytics,代碼行數:23,代碼來源:RoomDeserializer.java

示例7: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public User deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException,
        JsonProcessingException {

    ObjectCodec oc = jp.getCodec();
    JsonNode node = oc.readTree(jp);
    int userId = node.get("user_id").asInt();
    String email = node.get("email").asText();
    boolean deleted = node.get("is_deleted").asBoolean();
    boolean groupAdmin = node.get("is_group_admin").asBoolean();
    String name = node.get("name").asText();
    String mentionName = node.get("mention_name").asText();
    String photoUrl = node.get("photo_url").asText();
    DateTime lastActiveDate = new DateTime(node.get("last_active").asLong() * 1000L);
    DateTime creationDate = new DateTime(node.get("created").asLong() * 1000L);
    String status = node.get("status").asText();
    String statusMessage = node.get("status_message").asText();
    String timezone = node.get("timezone").asText();
    String title = node.get("title").asText();

    return new User(String.valueOf(userId), email, deleted, groupAdmin, false, name,
                    mentionName, photoUrl, lastActiveDate, creationDate, status, statusMessage,
                    timezone, title);
}
 
開發者ID:OpenChatAlytics,項目名稱:OpenChatAlytics,代碼行數:25,代碼來源:UserDeserializer.java

示例8: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public ChatAlyticsEvent deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    ObjectCodec oc = jp.getCodec();
    JsonNode node = oc.readTree(jp);

    JsonParser eventTimeParser = node.get("event_time").traverse();
    DateTime eventTime = oc.readValue(eventTimeParser, DateTime.class);

    String type = node.get("type").asText();

    Class<?> clazz;
    String classStr = node.get("clazz").asText();
    try {
        clazz = Class.forName(classStr);
    } catch (ClassNotFoundException e) {
        throw new IOException("Can't load class for " + classStr, e);
    }

    JsonParser eventParser = node.get("event").traverse();
    Object event = oc.readValue(eventParser, clazz);

    return new ChatAlyticsEvent(eventTime, type, event);
}
 
開發者ID:OpenChatAlytics,項目名稱:OpenChatAlytics,代碼行數:26,代碼來源:ChatAlyticsEventDeserializer.java

示例9: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public AbstractRestException deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException {
	ObjectCodec oc = jsonParser.getCodec();
	JsonNode node = oc.readTree(jsonParser);
	ObjectMapper mapper = (ObjectMapper) jsonParser.getCodec();
	if (node.get("type") != null) {
		String type = node.get("type")
				.textValue();
		Errors et = Errors.valueByName(type);
		if (et == null) {
			log.error("Could not find matching error type for type id {" + type + "}");
			throw new MeshJsonException("Invalid error type {" + type + "}");
		}
		return (AbstractRestException) mapper.convertValue(node, et.getClazz());
	}
	return null;
}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:18,代碼來源:RestExceptionDeserializer.java

示例10: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public ExposedPorts deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException {

    List<ExposedPort> exposedPorts = new ArrayList<>();
    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);
    for (Iterator<Map.Entry<String, JsonNode>> it = node.fields(); it.hasNext(); ) {

        Map.Entry<String, JsonNode> field = it.next();
        if (!field.getValue().equals(NullNode.getInstance())) {
            exposedPorts.add(ExposedPort.parse(field.getKey()));
        }
    }
    return new ExposedPorts(exposedPorts.toArray(new ExposedPort[0]));
}
 
開發者ID:codeabovelab,項目名稱:haven-platform,代碼行數:17,代碼來源:ExposedPorts.java

示例11: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public ResultSet deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {

    ObjectCodec objectCodec = jp.getCodec();
    JsonNode node = objectCodec.readTree(jp);
    long resultSize = node.get("resultSize").asLong();
    long startOffset = node.get("startOffset").asLong();
    List results = new ArrayList<>();
    if (node.get("results").isArray() && node.get("results").size() > 0) {
        JsonNode first = node.get("results").get(0);
        boolean resourceNode = first.get("children") != null;
        boolean resourceWithType = first.get("type") != null;
        Iterator<JsonNode> elements = node.get("results").elements();
        while (elements.hasNext()) {
            JsonNode element = elements.next();
            if (resourceNode) {
                results.add(objectCodec.treeToValue(element, ResourceNode.class));
            } else if (resourceWithType) {
                results.add(objectCodec.treeToValue(element, Resource.class));
            } else {
                results.add(objectCodec.treeToValue(element, ResourceType.class));
            }
        }
    }
    return new ResultSet(results, resultSize, startOffset);
}
 
開發者ID:hawkular,項目名稱:hawkular-commons,代碼行數:27,代碼來源:JacksonDeserializer.java

示例12: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public TalkListResponse deserialize(JsonParser jsonParser, DeserializationContext ctxt) throws IOException, JsonProcessingException {

    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);
    TalkListResponse responseData = new TalkListResponse();
    if (node.has("results")) {
        String nodeAsString = node.get("results").toString();
        ArrayList<Talk> talks = new ObjectMapper().readValue(nodeAsString , new TypeReference<ArrayList<Talk>>() {
        });
        responseData.setTalkList(talks);
    } else {
        responseData.setResponseError(new WrappedError(new Exception("Error while deserializing response result")));
    }
    return responseData;
}
 
開發者ID:viniciusDSL,項目名稱:Google-I-O-extended,代碼行數:17,代碼來源:TalkListDeserializer.java

示例13: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public TeamTagMap deserialize(JsonParser jsonParser, DeserializationContext deserializationContext)
        throws IOException {
    final Map<TagId,Integer> tagToTeam = new HashMap<>();
    ObjectCodec oc = jsonParser.getCodec();
    JsonNode node = oc.readTree(jsonParser);
    node.fields().forEachRemaining((entry) -> {
        int team = Integer.parseInt(entry.getKey(), 10);
        entry.getValue().elements().forEachRemaining((tagNode) -> {
            String tagStr = tagNode.asText();
            try {
            	tagToTeam.put(new TagId(tagStr), team);
            } catch (IllegalArgumentException e) {
            	// TODO: Handle this exception!!!!
            	LOG.error("Error decoding tag id: {}", tagStr, e);
            }
        });
    });
    return new TeamTagMap(ImmutableMap.<TagId,Integer>builder()
        .putAll(tagToTeam).build());
}
 
開發者ID:ULYSSIS-KUL,項目名稱:ipp,代碼行數:22,代碼來源:TeamTagMap.java

示例14: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public TeamState deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    ObjectCodec oc = jp.getCodec();
    JsonNode node = oc.readTree(jp);
    Iterator<Map.Entry<String, JsonNode>> it = node.fields();
    Optional<TagSeenEvent> lastTagSeenEvent = Optional.empty();
    int tagFragmentCount = 0;
    double speed = Double.NaN;
    double predictedSpeed = Double.NaN;
    while (it.hasNext()) {
        Map.Entry<String, JsonNode> entry = it.next();
        if (entry.getKey().equals("lastTagSeenEvent")) {
            TagSeenEvent event = oc.treeAsTokens(entry.getValue()).readValueAs(TagSeenEvent.class);
            lastTagSeenEvent = Optional.of(event);
        } else if (entry.getKey().equals("tagFragmentCount")) {
            tagFragmentCount = oc.treeAsTokens(entry.getValue()).getIntValue();
        } else if (entry.getKey().equals("speed")) {
            speed = oc.treeAsTokens(entry.getValue()).getDoubleValue();
        } else if (entry.getKey().equals("predictedSpeed")) {
            predictedSpeed = oc.treeAsTokens(entry.getValue()).getDoubleValue();
        }
    }
    return new TeamState(lastTagSeenEvent, tagFragmentCount, speed, predictedSpeed);
}
 
開發者ID:ULYSSIS-KUL,項目名稱:ipp,代碼行數:25,代碼來源:TeamState.java

示例15: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入方法依賴的package包/類
@Override
public Map<String, Action> deserialize(JsonParser parser, DeserializationContext context) throws IOException {
	ObjectCodec codec = parser.getCodec();
	Map<String, Action> map = new HashMap<>();
	final JsonNode node = codec.readTree(parser);
	if (node.has(DOWNLOAD_KEY)) {
		map.put(DOWNLOAD_KEY, deserializeAction(node, DOWNLOAD_KEY, codec, DownloadAction.class));
	}
	if (node.has(UPLOAD_KEY)) {
		map.put(UPLOAD_KEY, deserializeAction(node, UPLOAD_KEY, codec, UploadAction.class)); 
	}
	if (node.has(RUN_KEY)) {
		map.put(RUN_KEY, deserializeAction(node, RUN_KEY, codec, RunAction.class));
	}
	return (map.size() == 0) ? null : map;
}
 
開發者ID:cloudfoundry-attic,項目名稱:receptor-client,代碼行數:17,代碼來源:ActionMapDeserializer.java


注:本文中的com.fasterxml.jackson.core.ObjectCodec.readTree方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。