コード例 #1
0
 // [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"));
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 public MapBean() {
   values = new LinkedHashMap<String, Integer>();
   values.put("a", 1);
   values.put("b", 5);
   values.put("c", 9);
 }
コード例 #4
0
 @JsonAnySetter
 public void addAdditionalProperty(String key, Object value) {
   if (additionalProperties == null) additionalProperties = new HashMap<String, Object>();
   additionalProperties.put(key, value);
 }
コード例 #5
0
 public MyBean661(String value) {
   foo.put(Foo661.FOO, value);
 }
コード例 #6
0
 public MyStuff594(String value) {
   stuff.put(MyEnum594.VALUE_WITH_A_REALLY_LONG_NAME_HERE, value);
 }
コード例 #7
0
 public void add(TestEnum key, int value) {
   map.put(key, Integer.valueOf(value));
 }