JSON { public static String toJSONString(Object object) { return JSONSerializer.serialize(object); }  static String toJSONString(Object object); static String toJSONString(Object object, boolean addType); static T parseObject(String text, Class<T> clazz); static final String CLASS_KEY; }
@Test public void test() { TestJsonBean bean = new TestJsonBean(); bean.setName("xxxx"); bean.setAge(123); String str = JSON.toJSONString(bean); Assert.assertTrue(str.contains("\"Name\":\"xxxx\"")); str = JSON.toJSONString(bean, true); Assert.assertTrue(str.contains(JSON.CLASS_KEY)); }