com.fasterxml.jackson.databind.ser.SerializerFactory Java Examples
The following examples show how to use
com.fasterxml.jackson.databind.ser.SerializerFactory.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MappingJackson2XmlViewTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void renderWithCustomSerializerLocatedByFactory() throws Exception { SerializerFactory factory = new DelegatingSerializerFactory(null); XmlMapper mapper = new XmlMapper(); mapper.setSerializerFactory(factory); view.setObjectMapper(mapper); Object bean = new TestBeanSimple(); Map<String, Object> model = new HashMap<>(); model.put("foo", bean); view.render(model, request, response); String result = response.getContentAsString(); assertTrue(result.length() > 0); assertTrue(result.contains("custom</testBeanSimple>")); validateResult(); }
Example #2
Source File: MappingJackson2JsonViewTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void renderWithCustomSerializerLocatedByFactory() throws Exception { SerializerFactory factory = new DelegatingSerializerFactory(null); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializerFactory(factory); view.setObjectMapper(mapper); Object bean = new TestBeanSimple(); Map<String, Object> model = new HashMap<>(); model.put("foo", bean); model.put("bar", new TestChildBean()); view.render(model, request, response); String result = response.getContentAsString(); assertTrue(result.length() > 0); assertTrue(result.contains("\"foo\":{\"testBeanSimple\":\"custom\"}")); validateResult(); }
Example #3
Source File: MappingJackson2XmlViewTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void renderWithCustomSerializerLocatedByFactory() throws Exception { SerializerFactory factory = new DelegatingSerializerFactory(null); XmlMapper mapper = new XmlMapper(); mapper.setSerializerFactory(factory); view.setObjectMapper(mapper); Object bean = new TestBeanSimple(); Map<String, Object> model = new HashMap<>(); model.put("foo", bean); view.render(model, request, response); String result = response.getContentAsString(); assertTrue(result.length() > 0); assertTrue(result.contains("custom</testBeanSimple>")); validateResult(); }
Example #4
Source File: MappingJackson2JsonViewTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void renderWithCustomSerializerLocatedByFactory() throws Exception { SerializerFactory factory = new DelegatingSerializerFactory(null); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializerFactory(factory); view.setObjectMapper(mapper); Object bean = new TestBeanSimple(); Map<String, Object> model = new HashMap<String, Object>(); model.put("foo", bean); model.put("bar", new TestChildBean()); view.render(model, request, response); String result = response.getContentAsString(); assertTrue(result.length() > 0); assertTrue(result.contains("\"foo\":{\"testBeanSimple\":\"custom\"}")); validateResult(); }
Example #5
Source File: MappingJackson2XmlViewTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void renderWithCustomSerializerLocatedByFactory() throws Exception { SerializerFactory factory = new DelegatingSerializerFactory(null); XmlMapper mapper = new XmlMapper(); mapper.setSerializerFactory(factory); view.setObjectMapper(mapper); Object bean = new TestBeanSimple(); Map<String, Object> model = new HashMap<String, Object>(); model.put("foo", bean); view.render(model, request, response); String result = response.getContentAsString(); assertTrue(result.length() > 0); assertTrue(result.contains("custom</testBeanSimple>")); validateResult(); }
Example #6
Source File: MappingJackson2JsonViewTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void renderWithCustomSerializerLocatedByFactory() throws Exception { SerializerFactory factory = new DelegatingSerializerFactory(null); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializerFactory(factory); view.setObjectMapper(mapper); Object bean = new TestBeanSimple(); Map<String, Object> model = new HashMap<>(); model.put("foo", bean); model.put("bar", new TestChildBean()); view.render(model, request, response); String result = response.getContentAsString(); assertTrue(result.length() > 0); assertTrue(result.contains("\"foo\":{\"testBeanSimple\":\"custom\"}")); validateResult(); }
Example #7
Source File: CustomBeanSerializerFactory.java From caravan with Apache License 2.0 | 5 votes |
@Override public SerializerFactory withConfig(SerializerFactoryConfig config) { if (_factoryConfig == config) { return this; } if (getClass() != CustomBeanSerializerFactory.class) { throw new IllegalStateException("Subtype of BeanSerializerFactory ("+getClass().getName() +") has not properly overridden method 'withAdditionalSerializers': can not instantiate subtype with " +"additional serializer definitions"); } return new CustomBeanSerializerFactory(config); }
Example #8
Source File: JacksonJsonViewUnitTest.java From tutorials with MIT License | 5 votes |
@Test public void whenUseCustomJsonViewToSerialize_thenCorrect() throws JsonProcessingException { final User user = new User(1, "John"); final SerializerFactory serializerFactory = BeanSerializerFactory.instance.withSerializerModifier(new MyBeanSerializerModifier()); final ObjectMapper mapper = new ObjectMapper(); mapper.setSerializerFactory(serializerFactory); final String result = mapper.writerWithView(Views.Public.class) .writeValueAsString(user); assertThat(result, containsString("JOHN")); assertThat(result, containsString("1")); }
Example #9
Source File: StdSerializerProvider.java From maven-archetype with GNU Lesser General Public License v2.1 | 4 votes |
@Override public StdSerializerProvider createInstance(SerializationConfig config, SerializerFactory jsf) { return new StdSerializerProvider(this, config, jsf); }
Example #10
Source File: StdSerializerProvider.java From maven-archetype with GNU Lesser General Public License v2.1 | 4 votes |
protected StdSerializerProvider(SerializerProvider src, SerializationConfig config,SerializerFactory f) { super(src, config, f); }
Example #11
Source File: ConfigurableSerializerProvider.java From brooklyn-server with Apache License 2.0 | 4 votes |
public ConfigurableSerializerProvider(SerializationConfig config, ConfigurableSerializerProvider src, SerializerFactory jsf) { super(src, config, jsf); unknownTypeSerializer = src.unknownTypeSerializer; }
Example #12
Source File: ConfigurableSerializerProvider.java From brooklyn-server with Apache License 2.0 | 4 votes |
@Override public DefaultSerializerProvider createInstance(SerializationConfig config, SerializerFactory jsf) { return new ConfigurableSerializerProvider(config, this, jsf); }
Example #13
Source File: GridJettyObjectMapper.java From ignite with Apache License 2.0 | 4 votes |
/** {@inheritDoc} */ @Override public DefaultSerializerProvider createInstance(SerializationConfig cfg, SerializerFactory jsf) { return new CustomSerializerProvider(this, cfg, jsf); }
Example #14
Source File: NullSerializationTest.java From jackson-modules-base with Apache License 2.0 | 4 votes |
public MyNullSerializerProvider(TokenStreamFactory streamFactory, SerializerCache cache, SerializationConfig config, GeneratorSettings genSettings, SerializerFactory f) { super(streamFactory, config, genSettings, f, cache); }
Example #15
Source File: NullSerializationTest.java From jackson-modules-base with Apache License 2.0 | 4 votes |
@Override public SerializationContexts forMapper(Object mapper, TokenStreamFactory tsf, SerializerFactory serializerFactory, SerializerCache cache) { return new MyNullSerializerContexts(tsf, serializerFactory, cache); }
Example #16
Source File: NullSerializationTest.java From jackson-modules-base with Apache License 2.0 | 4 votes |
public MyNullSerializerContexts(TokenStreamFactory tsf, SerializerFactory serializerFactory, SerializerCache cache) { super(tsf, serializerFactory, cache); }
Example #17
Source File: GridJettyObjectMapper.java From ignite with Apache License 2.0 | 2 votes |
/** * Full constructor. * * @param src Blueprint object used as the baseline for this instance. * @param cfg Provider configuration. * @param f Serializers factory. */ CustomSerializerProvider(SerializerProvider src, SerializationConfig cfg, SerializerFactory f) { super(src, cfg, f); }