// [Issue#232] public void testBigDecimalAsPlainStringTreeConversion() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.enable(SerializationFeature.WRITE_BIGDECIMAL_AS_PLAIN); Map<String, Object> map = new HashMap<String, Object>(); String PI_STR = "3.00000000"; map.put("pi", new BigDecimal(PI_STR)); JsonNode tree = mapper.valueToTree(map); assertNotNull(tree); assertEquals(1, tree.size()); assertTrue(tree.has("pi")); }
public void testSimpleKeySer() throws Exception { ObjectMapper mapper = new ObjectMapper(); SimpleModule module = new SimpleModule("test", Version.unknownVersion()); module.addKeySerializer(String.class, new ContextualKeySerializer("prefix")); mapper.registerModule(module); Map<String, Object> input = new HashMap<String, Object>(); input.put("a", Integer.valueOf(3)); String json = mapper .writerWithType( TypeFactory.defaultInstance() .constructMapType(HashMap.class, String.class, Object.class)) .writeValueAsString(input); assertEquals("{\"prefix:a\":3}", json); }
public MapBean() { values = new LinkedHashMap<String, Integer>(); values.put("a", 1); values.put("b", 5); values.put("c", 9); }
@JsonAnySetter public void addAdditionalProperty(String key, Object value) { if (additionalProperties == null) additionalProperties = new HashMap<String, Object>(); additionalProperties.put(key, value); }
public MyBean661(String value) { foo.put(Foo661.FOO, value); }
public MyStuff594(String value) { stuff.put(MyEnum594.VALUE_WITH_A_REALLY_LONG_NAME_HERE, value); }
public void add(TestEnum key, int value) { map.put(key, Integer.valueOf(value)); }