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


Java ObjectCodec類代碼示例

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


ObjectCodec類屬於com.fasterxml.jackson.core包,在下文中一共展示了ObjectCodec類的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: gsonMap2Map

import com.fasterxml.jackson.core.ObjectCodec; //導入依賴的package包/類
/**
 * Десериализатор Gson Map в Map&lt;String, String&gt; значение
 * 
 * @param parser
 *            Gson строка
 * @throws IOException
 *             исключение парсера
 * @return карта
 */
public static Map<String, String> gsonMap2Map(JsonParser parser) throws IOException {
	ObjectCodec codec = parser.getCodec();
	TreeNode node = codec.readTree(parser);
	Map<String, String> ret = new HashMap<String, String>();
	if (node.isObject()) {
		for (Iterator<String> iter = node.fieldNames(); iter.hasNext();) {
			String fieldName = iter.next();
			TreeNode field = node.get(fieldName);
			if (field != null) {
				ret.put(fieldName, field.toString());
			} else {
				ret.put(fieldName, "null");
			}
		}
	}
	return ret;
}
 
開發者ID:onixred,項目名稱:golos4j,代碼行數:27,代碼來源:Util.java

示例3: 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;
  } else {
    return Arrays.asList(node.textValue());
  }
}
 
開發者ID:pinterest,項目名稱:soundwave,代碼行數:17,代碼來源:StringListOrElementDeserializer.java

示例4: 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

示例5: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入依賴的package包/類
@Override
public T deserialize(JsonParser jsonParser,
                     DeserializationContext deserializationContext) throws IOException,
        JsonProcessingException {
    ObjectCodec objectCodec = jsonParser.getCodec();
    JsonNode node = objectCodec.readTree(jsonParser);
    Class<? extends T> typeClass = null;
    if (node.isObject() && node.has("type")) {
        JsonNode type = node.get("type");
        if (type != null && type.isTextual()) {
            typeClass = registry.get(type.textValue());
        }
    }

    if (typeClass == null) {
        return null;
    }

    StringWriter writer = new StringWriter();
    objectMapper.writeValue(writer, node);
    writer.close();
    String json = writer.toString();
    return objectMapper.readValue(json, typeClass);
}
 
開發者ID:Esri,項目名稱:server-extension-java,代碼行數:25,代碼來源:AbstractTypedObjectDeserializer.java

示例6: 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

示例7: deserialize

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

    final Dienstbundel dienstbundel =
            entityManager.getReference(Dienstbundel.class, JsonUtils.getAsInteger(node, DienstbundelLo3RubriekModule.DIENSTBUNDEL));
    final Lo3Rubriek rubriek = entityManager.getReference(Lo3Rubriek.class, JsonUtils.getAsInteger(node, DienstbundelLo3RubriekModule.RUBRIEK));
    final nl.bzk.algemeenbrp.dal.domein.brp.entity.DienstbundelLo3Rubriek dienstbundelLO3Rubriek;
    if (JsonUtils.getAsInteger(node, DienstbundelLo3RubriekModule.ID) != null) {
        dienstbundelLO3Rubriek =
                entityManager.getReference(
                    nl.bzk.algemeenbrp.dal.domein.brp.entity.DienstbundelLo3Rubriek.class,
                    JsonUtils.getAsInteger(node, DienstbundelLo3RubriekModule.ID));

    } else {
        dienstbundelLO3Rubriek = new nl.bzk.algemeenbrp.dal.domein.brp.entity.DienstbundelLo3Rubriek(dienstbundel, rubriek);
    }
    final Boolean actief = JsonUtils.getAsBoolean(node, DienstbundelLo3RubriekModule.ACTIEF, "Ja", Boolean.TRUE, Boolean.FALSE);
    final DienstbundelLo3RubriekView viewRubriek = new DienstbundelLo3RubriekView(dienstbundelLO3Rubriek, actief);
    dienstbundelLO3Rubriek.setId(JsonUtils.getAsInteger(node, DienstbundelLo3RubriekModule.ID));

    return viewRubriek;

}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:26,代碼來源:DienstbundelLo3RubriekDeserializer.java

示例8: deserialize

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

    final SoortActie soortActie = EnumUtils.getAsEnum(SoortActie.class, JsonUtils.getAsInteger(node, SoortActieBrongebruikModule.SOORT_ACTIE));
    final SoortAdministratieveHandeling soortAdministratieveHandeling =
            EnumUtils.getAsEnum(
                    SoortAdministratieveHandeling.class,
                    JsonUtils.getAsInteger(node, SoortActieBrongebruikModule.SOORT_ADMINISTRATIEVE_HANDELING));
    final SoortDocument soortDocument =
            entityManager.find(SoortDocument.class, JsonUtils.getAsShort(node, SoortActieBrongebruikModule.SOORT_DOCUMENT));

    final SoortActieBrongebruikSleutel soortActieBrongebruikSleutel =
            new SoortActieBrongebruikSleutel(soortActie, soortAdministratieveHandeling, soortDocument);

    final SoortActieBrongebruik soortActieBrongebruik = new SoortActieBrongebruik(soortActieBrongebruikSleutel);

    soortActieBrongebruik.setId(JsonUtils.getAsShort(node, SoortActieBrongebruikModule.ID));
    soortActieBrongebruik.setDatumAanvangGeldigheid(JsonUtils.getAsInteger(node, SoortActieBrongebruikModule.DATUM_AANVANG_GELDIGHEID));
    soortActieBrongebruik.setDatumEindeGeldigheid(JsonUtils.getAsInteger(node, SoortActieBrongebruikModule.DATUM_EINDE_GELDIGHEID));

    return soortActieBrongebruik;
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:25,代碼來源:SoortActieBrongebruikDeserializer.java

示例9: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: deserialize

import com.fasterxml.jackson.core.ObjectCodec; //導入依賴的package包/類
@Override
public List<String> deserialize(JsonParser p, DeserializationContext ctxt)
		throws IOException, JsonProcessingException {		
	List<String> result;

	 ObjectCodec codec = p.getCodec();
	 

	if (p.getCurrentToken().equals(JsonToken.START_ARRAY)) {
		result = codec.readValue(p, new TypeReference<List<String>>() { });
	} else {
		LinkedHashMap<Integer, String> map = codec.readValue(p,
				new TypeReference<LinkedHashMap<Integer, String>>() { });
		
		result = new ArrayList<String>(map.values());
	}
	return result;
}
 
開發者ID:heindorf,項目名稱:cikm16-wdvd-feature-extraction,代碼行數:19,代碼來源:OldAliasListDeserializer.java

示例15: deserialize

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

	LinkedHashMap<String, String> result = null;

	// Is the alias broken, i.e., it starts with '['
	if (jp.getCurrentToken().equals(JsonToken.START_ARRAY)) {
		result = new LinkedHashMap<String, String>();
		jp.nextToken();
		if (!jp.getCurrentToken().equals(JsonToken.END_ARRAY)) {
			logger.warn("Token " + JsonToken.END_ARRAY + " expected");
		}			
	} else {
		ObjectCodec mapper = jp.getCodec();
		result = mapper.readValue(jp,
				new TypeReference<LinkedHashMap<String, String>>() { });
	}

	return result;
}
 
開發者ID:heindorf,項目名稱:cikm16-wdvd-feature-extraction,代碼行數:23,代碼來源:OldLabelsDescriptionsDeserializer.java


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