当前位置: 首页>>代码示例>>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;未经允许,请勿转载。