Examples of SimpleModule


Examples of com.fasterxml.jackson.databind.module.SimpleModule

    @Test
    public void testPolymorphicJacksonSerializationAndDeserialization()
    {
        ObjectMapper mapper = new ObjectMapper();

        SimpleModule testModule = new SimpleModule("testModule", new Version(1, 0, 0, null, null, null))
                .addDeserializer( QueryFilter.class, new QueryFilterDeserializer() );

        mapper.registerModule(testModule);

        // Verifying that we can pass in a custom Mapper and create a new JsonUtil
View Full Code Here

Examples of com.fasterxml.jackson.databind.module.SimpleModule

        final UUID id = UUID.fromString("AF4B5965-B176-4552-B3C1-FBBE2F52C305");
        g.addVertex(T.id, new CustomId("vertex", id));

        // todo: already registered a SimpleModule here......what do vendors do who already define one?

        final SimpleModule module = new SimpleModule();
        module.addSerializer(CustomId.class, new CustomId.CustomIdJacksonSerializer());
        module.addDeserializer(CustomId.class, new CustomId.CustomIdJacksonDeserializer());
        final GraphWriter writer = GraphSONWriter.build()
                .embedTypes(true)
                .customModule(module).create();

        try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
View Full Code Here

Examples of com.fasterxml.jackson.databind.module.SimpleModule

    protected void registerModule() throws Exception {
        if (customSerializers != null) {
            if (objectMapper == null) {
                objectMapper = new ObjectMapper(jsonFactory);
            }
            final SimpleModule simpleModule = new SimpleModule("customSerializer-module");
            for (final Class aClass : customSerializers) {
                simpleModule.addSerializer(aClass, (JsonSerializer) aClass.newInstance());
            }
            objectMapper.registerModule(simpleModule);
        }
    }
View Full Code Here

Examples of com.fasterxml.jackson.databind.module.SimpleModule

    protected void registerModule() throws Exception {
        if (customDeserializers != null) {
            if (objectMapper == null) {
                objectMapper = new ObjectMapper(jsonFactory);
            }
            final SimpleModule simpleModule = new SimpleModule("customDeserializer-module");
            for (final Class aClass : customDeserializers) {
                simpleModule.addDeserializer(aClass, (JsonDeserializer) aClass.newInstance());
            }
            objectMapper.registerModule(simpleModule);
        }
    }
View Full Code Here

Examples of com.fasterxml.jackson.databind.module.SimpleModule

        Assert.assertNotNull(bean.location);
        Assert.assertEquals(StackTraceBean.NUM, bean.location.getLineNumber());

        // and then directly, iff registered
        ObjectMapper mapper = new ObjectMapper();
        SimpleModule module = new SimpleModule();
        module.addDeserializer(StackTraceElement.class, new Jackson429StackTraceElementDeserializer());
        mapper.registerModule(module);

        StackTraceElement elem = mapper.readValue(
                aposToQuotes("{'class':'package.SomeClass','method':'someMethod','file':'SomeClass.java','line':123}"),
                StackTraceElement.class);
View Full Code Here

Examples of com.fasterxml.jackson.databind.module.SimpleModule

        Assert.assertNotNull(bean.location);
        Assert.assertEquals(StackTraceBean.NUM, bean.location.getLineNumber());

        // and then directly, iff registered
        ObjectMapper mapper = new ObjectMapper();
        SimpleModule module = new SimpleModule();
        module.addDeserializer(StackTraceElement.class, new MyStackTraceElementDeserializer());
        mapper.registerModule(module);

        StackTraceElement elem = mapper.readValue(
                aposToQuotes("{'class':'package.SomeClass','method':'someMethod','file':'SomeClass.java','line':13}"),
                StackTraceElement.class);
View Full Code Here

Examples of com.fasterxml.jackson.databind.module.SimpleModule

  public PhysicalPlanReader(DrillConfig config, ObjectMapper mapper, final DrillbitEndpoint endpoint,
                            final StorageEngineRegistry engineRegistry) {

    // Endpoint serializer/deserializer.
    SimpleModule deserModule = new SimpleModule("PhysicalOperatorModule") //
        .addSerializer(DrillbitEndpoint.class, new DrillbitEndpointSerDe.Se()) //
        .addDeserializer(DrillbitEndpoint.class, new DrillbitEndpointSerDe.De()) //
        .addSerializer(MajorType.class, new MajorTypeSerDe.Se())
        .addDeserializer(MajorType.class, new MajorTypeSerDe.De());
       
View Full Code Here

Examples of com.fasterxml.jackson.databind.module.SimpleModule

  @VisibleForTesting
  public DrillConfig(Config config) {
    super(config);
    mapper = new ObjectMapper();
    SimpleModule deserModule = new SimpleModule("LogicalExpressionDeserializationModule")
      .addDeserializer(LogicalExpression.class, new LogicalExpression.De(this));
   
    mapper.registerModule(deserModule);
    mapper.enable(SerializationFeature.INDENT_OUTPUT);
    mapper.configure(Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
View Full Code Here

Examples of com.fasterxml.jackson.databind.module.SimpleModule

    if (this.dateFormat != null) {
      this.objectMapper.setDateFormat(this.dateFormat);
    }

    if (this.serializers != null || this.deserializers != null) {
      SimpleModule module = new SimpleModule();
      addSerializers(module);
      addDeserializers(module);
      this.objectMapper.registerModule(module);
    }
View Full Code Here

Examples of com.fasterxml.jackson.databind.module.SimpleModule

   *
   * @param json
   *            is the {@link ObjectMapper} to augment
   */
  protected static ObjectMapper configure(final ObjectMapper json) {
    final SimpleModule jodaModule = new SimpleModule("Joda");
    jodaModule.addSerializer(new JodaDateTimeSerializer());
    jodaModule.addDeserializer(DateTime.class, new JodaDateTimeDeserializer());
    json.registerModule(jodaModule);

    // Increase performance even more
    json.registerModule(new AfterburnerModule());
    return json;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.