Package org.codehaus.jackson.map.module

Examples of org.codehaus.jackson.map.module.SimpleModule


import org.codehaus.jackson.map.module.SimpleModule;

public class EndpointObjectMapper extends ObjectMapper {

  public EndpointObjectMapper() {
    SimpleModule simpleModule = new SimpleModule("SimpleModule",
              new Version(1,0,0,null));
   
    simpleModule.addSerializer(EndpointResponse.class, new EndpointResponseSerializer());
    registerModule(simpleModule);
    configure(Feature.INDENT_OUTPUT, true);
  }
View Full Code Here


import org.codehaus.jackson.map.module.SimpleModule;

public class EndpointResponseObjectMapper extends ObjectMapper {

  public EndpointResponseObjectMapper() {
    SimpleModule simpleModule = new SimpleModule("SimpleModule",
              new Version(1,0,0,null));
   
    simpleModule.addSerializer(EndpointResponse.class, new EndpointResponseSerializer());
    registerModule(simpleModule);
    configure(Feature.INDENT_OUTPUT, true);
  }
View Full Code Here

   *         Samza's job data model, and simple data types such as TaskName,
   *         Partition, Config, and SystemStreamPartition.
   */
  public static ObjectMapper getObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    SimpleModule module = new SimpleModule("SamzaModule", new Version(1, 0, 0, ""));

    // Setup custom serdes for simple data types.
    module.addSerializer(Partition.class, new PartitionSerializer());
    module.addSerializer(SystemStreamPartition.class, new SystemStreamPartitionSerializer());
    module.addSerializer(TaskName.class, new TaskNameSerializer());
    module.addDeserializer(Partition.class, new PartitionDeserializer());
    module.addDeserializer(SystemStreamPartition.class, new SystemStreamPartitionDeserializer());
    module.addDeserializer(Config.class, new ConfigDeserializer());

    // Setup mixins for data models.
    mapper.getSerializationConfig().addMixInAnnotations(TaskModel.class, JsonTaskModelMixIn.class);
    mapper.getDeserializationConfig().addMixInAnnotations(TaskModel.class, JsonTaskModelMixIn.class);
    mapper.getSerializationConfig().addMixInAnnotations(ContainerModel.class, JsonContainerModelMixIn.class);
View Full Code Here

    }
  }

  public static String toJson(Object object) {
    ObjectMapper mapper = new ObjectMapper(new MyJsonFactory());
    SimpleModule module = new SimpleModule("fullcalendar", new Version(1, 0, 0, null));
    module.addSerializer(new DateTimeSerializer());
    module.addSerializer(new LocalTimeSerializer());
    mapper.registerModule(module);
    mapper.getSerializationConfig().setSerializationInclusion(Inclusion.NON_NULL);

    String json = null;
    try {
View Full Code Here

  @Provides
  @Singleton
  public ObjectMapper getObjectMapper(Injector injector) {
    ObjectMapper mapper = new ObjectMapper();

    SimpleModule module =
            new SimpleModule("MySerializer", new Version(1, 0, 0, null));

    module.addSerializer(SimpleEvaluationObject.class, injector.getInstance(SimpleEvaluationObject.Serializer.class));
    module.addSerializer(EvaluationResult.class, injector.getInstance(EvaluationResult.Serializer.class));
    module.addSerializer(TableDisplay.class, injector.getInstance(TableDisplay.Serializer.class));
    module.addSerializer(OutputContainer.class, injector.getInstance(OutputContainer.Serializer.class));
    module.addSerializer(StringObject.class, injector.getInstance(StringObject.Serializer.class));

    module.addSerializer(Color.class, injector.getInstance(ColorSerializer.class));
    module.addSerializer(XYChart.class, injector.getInstance(XYChartSerializer.class));
    module.addSerializer(CombinedPlot.class, injector.getInstance(CombinedPlotSerializer.class));
    module.addSerializer(Line.class, injector.getInstance(LineSerializer.class));
    module.addSerializer(Points.class, injector.getInstance(PointsSerializer.class));
    module.addSerializer(Bars.class, injector.getInstance(BarsSerializer.class));
    module.addSerializer(Stems.class, injector.getInstance(StemsSerializer.class));
    module.addSerializer(Area.class, injector.getInstance(AreaSerializer.class));
    module.addSerializer(YAxis.class, injector.getInstance(YAxisSerializer.class));
    module.addSerializer(Crosshair.class, injector.getInstance(CrosshairSerializer.class));

    mapper.registerModule(module);

    SerializationConfig config = mapper.getSerializationConfig();
View Full Code Here

  @Provides
  @Singleton
  public ObjectMapper getObjectMapper(Injector injector) {
    ObjectMapper mapper = new ObjectMapper();

    SimpleModule module =
            new SimpleModule("MySerializer", new Version(1, 0, 0, null));

    module.addSerializer(StringObject.class,
        injector.getInstance(StringObject.Serializer.class));
    module.addSerializer(SessionBackupRest.Plugin.class,
        injector.getInstance(SessionBackupRest.PluginSerializer.class));
    module.addSerializer(SessionBackupRest.Session.class,
        injector.getInstance(SessionBackupRest.SessionSerializer.class));

    mapper.registerModule(module);

    SerializationConfig config = mapper.getSerializationConfig();
View Full Code Here

    private static ObjectMapper createObjectMapper() {
        // it's a shame that the serialization and deserialization mechanism
        // used aren't symmetric... but it works.
        final DeserializerProvider deserializerProvider = new StdDeserializerProvider(new JsonRepresentationDeserializerFactory());
        final ObjectMapper objectMapper = new ObjectMapper(null, null, deserializerProvider);
        final SimpleModule jsonModule = new SimpleModule("json", new Version(1, 0, 0, null));
        jsonModule.addSerializer(JsonRepresentation.class, new JsonRepresentationSerializer());
        objectMapper.registerModule(jsonModule);

        objectMapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
        objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        return objectMapper;
View Full Code Here

    private static ObjectMapper createObjectMapper(PrettyPrinting prettyPrinting) {
        // it's a shame that the serialization and deserialization mechanism
        // used aren't symmetric... but it works.
        final DeserializerProvider deserializerProvider = new StdDeserializerProvider(new JsonRepresentationDeserializerFactory());
        final ObjectMapper objectMapper = new ObjectMapper(null, null, deserializerProvider);
        final SimpleModule jsonModule = new SimpleModule("json", new Version(1, 0, 0, null));
        jsonModule.addSerializer(JsonRepresentation.class, new JsonRepresentationSerializer());
        objectMapper.registerModule(jsonModule);

        if(prettyPrinting == PrettyPrinting.ENABLE) {
            objectMapper.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
        }
View Full Code Here

    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 =
View Full Code Here

     */

    public void testCustomDeserializers() throws Exception
    {
        ObjectMapper mapper = new ObjectMapper();
        SimpleModule testModule = new SimpleModule("test", Version.unknownVersion());
        testModule.addDeserializer(NonDeserializable[].class, new CustomNonDeserArrayDeserializer());
        mapper.registerModule(testModule);
       
        NonDeserializable[] result = mapper.readValue("[\"a\"]", NonDeserializable[].class);
        assertNotNull(result);
        assertEquals(1, result.length);
View Full Code Here

TOP

Related Classes of org.codehaus.jackson.map.module.SimpleModule

Copyright © 2018 www.massapicom. 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.