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


Java SimpleModule.addDeserializer方法代碼示例

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


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

示例1: read

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
private void read(DataInput in) throws IOException {
  ObjectMapper mapper = new ObjectMapper();
  mapper.configure(
      DeserializationConfig.Feature.CAN_OVERRIDE_ACCESS_MODIFIERS, true);
  
  // define a module
  SimpleModule module = new SimpleModule("State Serializer",  
      new Version(0, 1, 1, "FINAL"));
  // add the state deserializer
  module.addDeserializer(StatePair.class, new StateDeserializer());

  // register the module with the object-mapper
  mapper.registerModule(module);

  JsonParser parser = 
    mapper.getJsonFactory().createJsonParser((DataInputStream)in);
  StatePool statePool = mapper.readValue(parser, StatePool.class);
  this.setStates(statePool.getStates());
  parser.close();
}
 
開發者ID:Nextzero,項目名稱:hadoop-2.6.0-cdh5.4.3,代碼行數:21,代碼來源:StatePool.java

示例2: addDiscoverableDeserializers

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
/**
 * Search for any registered JsonDeserialize instances that have been declared using the
 * ServiceLoader. Add any found to the given mapper in a 'magic' module.
 */
private static void addDiscoverableDeserializers(final ObjectMapper mapper) {

    final ServiceLoader<JsonDeserializer> loader = ServiceLoader.load(JsonDeserializer.class);
    final Iterator<JsonDeserializer> iterator = loader.iterator();
    final SimpleModule magic = new SimpleModule("magic", new Version(1, 0, 0, ""));

    while (iterator.hasNext()) {

        final JsonDeserializer<?> deserializer = iterator.next();

        try {
            final Method deserialeMethod = deserializer.getClass()
                    .getDeclaredMethod("deserialize", JsonParser.class, DeserializationContext.class);
            final Class<?> jsonType = deserialeMethod.getReturnType();
            //noinspection unchecked
            magic.addDeserializer(jsonType, (JsonDeserializer) deserializer);
        }
        catch(Exception e) {
            throw new IllegalStateException(e);
        }
    }

    mapper.registerModule(magic);
}
 
開發者ID:NovaOrdis,項目名稱:playground,代碼行數:29,代碼來源:BasicObjectMapperProvider.java

示例3: convertJsonToDataWrapper

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
/**
 * Takes a JSON string that came from the frontend form submission and deserializes it into its {@link DataWrapper} dto
 * representation so that it can be converted to an MVEL expression
 * @param json
 * @return
 */
public DataWrapper convertJsonToDataWrapper(String json) {
    ObjectMapper mapper = new ObjectMapper();
    DataDTODeserializer dtoDeserializer = new DataDTODeserializer();
    SimpleModule module = new SimpleModule("DataDTODeserializerModule", new Version(1, 0, 0, null));
    module.addDeserializer(DataDTO.class, dtoDeserializer);
    mapper.registerModule(module);
    if (json == null || "[]".equals(json)) {
        return null;
    }

    try {
        return mapper.readValue(json, DataWrapper.class);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:23,代碼來源:RuleFieldExtractionUtility.java

示例4: QdsClientImpl

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
public QdsClientImpl(QdsConfiguration configuration)
{
    this.configuration = Preconditions.checkNotNull(configuration, "configuration cannot be null");
    client = configuration.newClient();
    target = client.target(configuration.getApiEndpoint()).path(configuration.getApiVersion());
    commandApi = new CommandApiImpl(this);
    clusterApi = new ClusterApiImpl(this);
    hiveMetadataApi = new HiveMetadataApiImpl(this);
    dbTapsApi = new DbTapApiImpl(this);
    reportApi = new ReportApiImpl(this);
    schedulerApi = new SchedulerApiImpl(this);
    appApi = new AppApiImpl(this);
    notebookApi = new NotebookApiImpl(this);

    // register the deserialization handler for composite command
    SimpleModule module =
            new SimpleModule("CommandResponseDeserializerModule",
                    new Version(1, 0, 0, null));
    SubCommandsDeserializer ccDeserializer = new SubCommandsDeserializer();
    module.addDeserializer(SubCommands.class, ccDeserializer);
    MAPPER.registerModule(module);
}
 
開發者ID:qubole,項目名稱:qds-sdk-java,代碼行數:23,代碼來源:QdsClientImpl.java

示例5: CustomJSONProvider

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
public CustomJSONProvider() {
    super();

    ObjectMapper mapper = new ObjectMapper();

    SimpleModule myModule = new SimpleModule("MyOpenDaylightOFFlowJSONSerializerDeserializerModule", new Version(1, 0, 0, null));
    myModule.addSerializer(new OpenDaylightOFFlowJSONSerializer()); // assuming OpenDaylightOFFlowJSONSerializer declares correct class to bind to
    myModule.addDeserializer(OpenDaylightOFFlow.class, new OpenDaylightOFFlowJSONDeserializer());
    myModule.addDeserializer(OpenDaylightOFFlowsWrapper.class, new OpenDaylightOFFlowsWrapperJSONDeserializer());
    mapper.registerModule(myModule);

    mapper.configure(org.codehaus.jackson.map.SerializationConfig.Feature.WRAP_ROOT_VALUE, false);
    mapper.configure(org.codehaus.jackson.map.SerializationConfig.Feature.INDENT_OUTPUT, true);
    // mapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true);
    mapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);

    super.setMapper(mapper);
}
 
開發者ID:dana-i2cat,項目名稱:opennaas-routing-nfv,代碼行數:19,代碼來源:CustomJSONProvider.java

示例6: CustomJSONProvider

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
public CustomJSONProvider() {
	super();

	ObjectMapper mapper = new ObjectMapper();

	SimpleModule myModule = new SimpleModule("MyFloodlightOFFlowJSONSerializerDeserializerModule", new Version(1, 0, 0, null));
	myModule.addSerializer(new FloodlightOFFlowJSONSerializer()); // assuming FloodlightOFFlowJSONSerializer declares correct class to bind to
	myModule.addDeserializer(FloodlightOFFlow.class, new FloodlightOFFlowJSONDeserializer());
	myModule.addDeserializer(FloodlightOFFlowsWrapper.class, new FloodlightOFFlowsWrapperJSONDeserializer());
	mapper.registerModule(myModule);

	mapper.configure(org.codehaus.jackson.map.SerializationConfig.Feature.WRAP_ROOT_VALUE, false);
	mapper.configure(org.codehaus.jackson.map.SerializationConfig.Feature.INDENT_OUTPUT, true);
	// mapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true);
	mapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);

	super.setMapper(mapper);
}
 
開發者ID:dana-i2cat,項目名稱:opennaas-routing-nfv,代碼行數:19,代碼來源:CustomJSONProvider.java

示例7: addJodaDeserializers

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
/**
 * Add Joda-Time deserializers to a module.
 */
private static void addJodaDeserializers(final SimpleModule module) {

    for (final StdDeserializer<?> deserializer : new JodaDeserializers().provide()) {
        module.addDeserializer((Class) deserializer.getValueClass(), deserializer);
    }
    module.addDeserializer(Duration.class, DurationDeserializer.create());
    module.addDeserializer(Instant.class, InstantDeserializer.create());
    module.addDeserializer(ReadableInstant.class, InstantDeserializer.create());
    module.addDeserializer(Interval.class, IntervalDeserializer.create());
    module.addDeserializer(LocalDate.class, LocalDateDeserializer.create());
}
 
開發者ID:NovaOrdis,項目名稱:playground,代碼行數:15,代碼來源:BasicObjectMapperProvider.java

示例8: deserializeToUser

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
private User deserializeToUser(String dataString) throws Exception {

        ObjectMapper mapper = new ObjectMapper();
        mapper.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);
        SimpleModule simpleModule = new SimpleModule("DeserializeToUserModule", new Version(1, 0, 0, ""));
        simpleModule.addDeserializer(User.class, new UserDeserializer());
        mapper.registerModule(simpleModule);

		return mapper.readValue(dataString, User.class);
	}
 
開發者ID:AgarwalNeha1,項目名稱:gluu,代碼行數:11,代碼來源:BulkWebService.java

示例9: convertJsonToDataWrapper

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
/**
 * When using Thymeleaf, we need to convert the JSON string back to
 * a DataWrapper object because Thymeleaf escapes JSON strings.
 * Thymeleaf uses it's own object de-serializer
 * see: https://github.com/thymeleaf/thymeleaf/issues/84
 * see: http://forum.thymeleaf.org/Spring-Javascript-and-escaped-JSON-td4024739.html
 * @param json
 * @return DataWrapper
 * @throws IOException
 */
protected DataWrapper convertJsonToDataWrapper(String json) {
    ObjectMapper mapper = new ObjectMapper();
    DataDTODeserializer dtoDeserializer = new DataDTODeserializer();
    SimpleModule module = new SimpleModule("DataDTODeserializerModule", new Version(1, 0, 0, null));
    module.addDeserializer(DataDTO.class, dtoDeserializer);
    mapper.registerModule(module);
    try {
        return mapper.readValue(json, DataWrapper.class);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:passion1014,項目名稱:metaworks_framework,代碼行數:23,代碼來源:FormBuilderServiceImpl.java

示例10: getCustomSimpleModuleWithXSS

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
public static SimpleModule getCustomSimpleModuleWithXSS() {
    //Define a SimpleModule to control Serialization mechanism.
    SimpleModule module = new SimpleModule("HTML XSS Serializer", new Version(1, 0, 0, "FINAL"));
    //module.addSerializer(String.class, new JSONHtmlXssSerializer());
    module.addDeserializer(String.class, new JSONStringXSSDeserializer());
    return module;
}
 
開發者ID:Appverse,項目名稱:appverse-server,代碼行數:8,代碼來源:JacksonContextResolver.java

示例11: RegisterSerializersObjectMapper

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
public RegisterSerializersObjectMapper() {
	System.out.println("Creating custom object mapper to include localdatetimeserializers");
	//try to register it here so it should not require annotations on our objects
	mapper = new ObjectMapper();
	SimpleModule serializersModule = new SimpleModule("[De]Serializers module", Version.unknownVersion());
	serializersModule.addSerializer(LocalDateTime.class, new  LocalDateTimeSerializer());
	serializersModule.addDeserializer(LocalDateTime.class, new  LocalDateTimeDeserializer());
	mapper.registerModule(serializersModule);
}
 
開發者ID:jesuino,項目名稱:bpms6-examples,代碼行數:10,代碼來源:RegisterSerializersObjectMapper.java

示例12: objectMapper

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
@Provides ObjectMapper objectMapper() {
  ObjectMapper mapper = new ObjectMapper();
  SimpleModule module = new SimpleModule("JSONModule", new Version(2, 0, 0, null));
  module.addSerializer(DateTime.class, new CustomDateSerializer());
  module.addDeserializer(DateTime.class, new CustomDateDeserializer());
  mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  mapper.registerModule(module);
  return mapper;
}
 
開發者ID:kevinmrohr,項目名稱:android-blog,代碼行數:10,代碼來源:ObjectMappingModule.java

示例13: getContext

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
@Override
public ObjectMapper getContext(Class<?> type)
{
    ItemDeserializer deserializer = new ItemDeserializer();
    deserializer.registerItem(NODE_ID, Node.class);
    SimpleModule module = new SimpleModule("PolymorphicItemDeserializerModule", new Version(1,
            0, 0, null));
    module.addDeserializer(DrupalEntity.class, deserializer);

    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(module);
    return mapper;
}
 
開發者ID:ryandcarter,項目名稱:drupal8-connector,代碼行數:14,代碼來源:DrupalHalProvider.java

示例14: CustomJSONProvider

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
public CustomJSONProvider() {
    super();

    ObjectMapper mapper = new ObjectMapper();

    SimpleModule myModule = new SimpleModule("MyOpenDaylightVTNJSONSerializerDeserializerModule", new Version(1, 0, 0, null));
    myModule.addSerializer(new VTNJSONSerializer()); // assuming OpenDaylightOFFlowJSONSerializer declares correct class to bind to
    myModule.addSerializer(new ControllerJSONSerializer());
    myModule.addSerializer(new vBridgeJSONSerializer());
    myModule.addSerializer(new vbrInterfaceJSONSerializer());
    myModule.addSerializer(new BoundaryJSONSerializer());
    myModule.addSerializer(new vLinkJSONSerializer());
    myModule.addSerializer(new PortMapJSONSerializer());
    myModule.addDeserializer(LogicalPortsOFFlowsWrapper.class, new LogicalPortsWrapperJSONDeserializer());
    myModule.addDeserializer(vBridgesWrapper.class, new vBridgesWrapperJSONDeserializer());
    myModule.addDeserializer(vBridgeInterfacesWrapper.class, new vBridgeInterfacesWrapperJSONDeserializer());
    myModule.addDeserializer(OpenDaylightvBridge.class, new vBridgeJSONDeserializer());
    myModule.addDeserializer(Boundary.class, new BoundaryJSONDeserializer());
    myModule.addDeserializer(BoundaryWrapper.class, new BoundaryWrapperJSONDeserializer());
    myModule.addDeserializer(vLink.class, new vLinkJSONDeserializer());
    myModule.addDeserializer(vLinksWrapper.class, new vLinksWrapperJSONDeserializer());
    myModule.addDeserializer(PortMap.class, new PortMapJSONDeserializer());
    myModule.addDeserializer(SwitchesWrapper.class, new SwitchesWrapperJSONDeserializer());
    mapper.registerModule(myModule);

    mapper.configure(org.codehaus.jackson.map.SerializationConfig.Feature.WRAP_ROOT_VALUE, false);
    mapper.configure(org.codehaus.jackson.map.SerializationConfig.Feature.INDENT_OUTPUT, true);
    // mapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true);
    mapper.configure(org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, true);

    super.setMapper(mapper);
}
 
開發者ID:dana-i2cat,項目名稱:opennaas-routing-nfv,代碼行數:33,代碼來源:CustomJSONProvider.java

示例15: CustomJacksonProviderScim2

import org.codehaus.jackson.map.module.SimpleModule; //導入方法依賴的package包/類
public CustomJacksonProviderScim2() {

        super();

        log.info(" CustomJacksonProviderScim2() ");

        ObjectMapper mapper = _mapperConfig.getDefaultMapper();
        mapper.disable(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS);
        mapper.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES);

        SimpleModule customJacksonModule = new SimpleModule("CustomJacksonModuleScim2", new Version(1, 0, 0, ""));

        customJacksonModule.addSerializer(User.class, new UserSerializer());
        customJacksonModule.addDeserializer(User.class, new UserDeserializer());

        mapper.registerModule(customJacksonModule);
    }
 
開發者ID:AgarwalNeha1,項目名稱:gluu,代碼行數:18,代碼來源:CustomJacksonProviderScim2.java


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