Java 类com.alibaba.fastjson.serializer.NameFilter 实例源码

项目:GitHub    文件:NameFilterTest_char.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {

            if (name.equals("id")) {
                Assert.assertTrue(value instanceof Character);
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":\"0\"}", text);
}
项目:GitHub    文件:NameFilterTest_char.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", '0');
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":\"0\"}", text);
}
项目:GitHub    文件:NameFilterTest_float.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0.0}", text);
}
项目:GitHub    文件:NameFilterTest_float.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_double.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0.0}", text);
}
项目:GitHub    文件:NameFilterTest_double.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_byte.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", (byte) 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterClassLevelTest.java   
public void test_0() throws Exception {
    Object[] array = { new ModelA(), new ModelB() };

    SerializeConfig config = new SerializeConfig();
    config.addFilter(ModelA.class, //
                     new PascalNameFilter());
    config.addFilter(ModelB.class, //
                     new NameFilter() {
                         @Override
                         public String process(Object object, String name, Object value) {
                             return name;
                         }
                     });
    String text2 = JSON.toJSONString(array, config);
    Assert.assertEquals("[{\"Id\":1001},{\"id\":1002}]", text2);

    String text = JSON.toJSONString(array);
    Assert.assertEquals("[{\"id\":1001},{\"id\":1002}]", text);

}
项目:GitHub    文件:NameFilterTest_short_field.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                Assert.assertTrue(value instanceof Short);
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", (short) 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_float_field.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0.0}", text);
}
项目:GitHub    文件:NameFilterTest_float_field.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_IntegerKey.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("1001")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map map = new HashMap();
    map.put(1001, 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_boolean_field.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", true);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":true}", text);
}
项目:GitHub    文件:NameFilterTest_long_field.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                Assert.assertTrue(value instanceof Long);
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_long_field.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_int_field.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                Assert.assertTrue(value instanceof Integer);
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_int_field.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_short.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                Assert.assertTrue(value instanceof Short);
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", (short) 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_int.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                Assert.assertTrue(value instanceof Integer);
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_int.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_byte_field.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", (byte) 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_boolean.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", true);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":true}", text);
}
项目:GitHub    文件:NameFilterTest_long.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                Assert.assertTrue(value instanceof Long);
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_long.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterClassLevelTest_private.java   
public void test_0() throws Exception {
    Object[] array = { new ModelA(), new ModelB() };

    SerializeConfig config = new SerializeConfig();
    config.addFilter(ModelA.class, //
                     new PascalNameFilter());
    config.addFilter(ModelB.class, //
                     new NameFilter() {
                         @Override
                         public String process(Object object, String name, Object value) {
                             return name;
                         }
                     });
    String text2 = JSON.toJSONString(array, config);
    Assert.assertEquals("[{\"Id\":1001},{\"id\":1002}]", text2);

    String text = JSON.toJSONString(array);
    Assert.assertEquals("[{\"id\":1001},{\"id\":1002}]", text);

}
项目:GitHub    文件:NameFilterTest.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_double_field.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0.0}", text);
}
项目:GitHub    文件:NameFilterTest_double_field.java   
public void test_namefilter_1() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Map<String, Object> map = new HashMap<String, Object>();
    map.put("id", 0);
    serializer.write(map);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:boohee_v5.6    文件:JSON.java   
private static void setFilter(JSONSerializer serializer, SerializeFilter filter) {
    if (filter != null) {
        if (filter instanceof PropertyPreFilter) {
            serializer.getPropertyPreFilters().add((PropertyPreFilter) filter);
        }
        if (filter instanceof NameFilter) {
            serializer.getNameFilters().add((NameFilter) filter);
        }
        if (filter instanceof ValueFilter) {
            serializer.getValueFilters().add((ValueFilter) filter);
        }
        if (filter instanceof PropertyFilter) {
            serializer.getPropertyFilters().add((PropertyFilter) filter);
        }
        if (filter instanceof BeforeFilter) {
            serializer.getBeforeFilters().add((BeforeFilter) filter);
        }
        if (filter instanceof AfterFilter) {
            serializer.getAfterFilters().add((AfterFilter) filter);
        }
    }
}
项目:GitHub    文件:Issue1274.java   
public void test_for_issue() throws Exception {

        User user = new User();
        user.setId(1);
        user.setName("name");

        NameFilter filter =  new NameFilter() {
            public String process(Object object, String name, Object value) {
                System.out.println("name="+name+",value="+value);
                if(name.equals("name")){
                    return "nt";
                }
                return name;
            }
        };

        // test for  JSON.toJSONString(user,filter);
        String jsonString = JSON.toJSONString(user,filter);
        System.out.println(jsonString);
        assertEquals("{\"id\":1,\"nt\":\"name\"}", jsonString);

        // test for jsonSerializer.getNameFilters().add(filter);
        JSONSerializer jsonSerializer = new JSONSerializer();
        jsonSerializer.getNameFilters().add(filter);
        jsonSerializer.write(user);
        jsonString = jsonSerializer.toString();
        System.out.println(jsonString);
        assertEquals("{\"id\":1,\"nt\":\"name\"}",jsonString);

    }
项目:GitHub    文件:Issue1524.java   
public void test_for_issue() throws Exception {
    Model model = new Model();
    model.oldValue = new Value();

    String json = JSON.toJSONString(model, new NameFilter() {
        public String process(Object object, String name, Object value) {
            if ("oldValue".equals(name)) {
                return "old_value";
            }
            return name;
        }
    });
    System.out.println(json);
}
项目:GitHub    文件:ClassNameFilterTest.java   
public void test_filter() throws Exception {
    NameFilter upcaseNameFilter = new NameFilter() {

        @Override
        public String process(Object object, String name, Object value) {
            return name.toUpperCase();
        }
    };
    SerializeConfig.getGlobalInstance() //
                   .addFilter(A.class, upcaseNameFilter);

    Assert.assertEquals("{\"ID\":0}", JSON.toJSONString(new A()));
    Assert.assertEquals("{\"id\":0}", JSON.toJSONString(new B()));
}
项目:GitHub    文件:NameFilterTest_byte.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (value != null) {
                Assert.assertTrue(value instanceof Byte);
            }

            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_short_field.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (value != null) {
                Assert.assertTrue(value instanceof Short);
            }

            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_boolean_field.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (value != null) {
                Assert.assertTrue(value instanceof Boolean);
            }

            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":false}", text);
}
项目:GitHub    文件:NameFilterTest_short.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (value != null) {
                Assert.assertTrue(value instanceof Short);
            }

            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_byte_field.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (value != null) {
                Assert.assertTrue(value instanceof Byte);
            }

            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":0}", text);
}
项目:GitHub    文件:NameFilterTest_boolean.java   
public void test_namefilter() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (value != null) {
                Assert.assertTrue(value instanceof Boolean);
            }

            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    SerializeWriter out = new SerializeWriter();
    JSONSerializer serializer = new JSONSerializer(out);
    serializer.getNameFilters().add(filter);

    Bean a = new Bean();
    serializer.write(a);

    String text = out.toString();
    Assert.assertEquals("{\"ID\":false}", text);
}
项目:GitHub    文件:NameFilterTest.java   
public static void test_toJSONString() throws Exception {
    NameFilter filter = new NameFilter() {

        public String process(Object source, String name, Object value) {
            if (name.equals("id")) {
                return "ID";
            }

            return name;
        }

    };

    Assert.assertEquals("{\"ID\":0}", JSON.toJSONString(Collections.singletonMap("id", 0), filter));
}