JsonCodec extends AbstractCodec { @Override public String encode(Object obj) { try { return objectMapper.writeValueAsString(obj); } catch (JsonProcessingException e) { throw new IllegalStateException("encode error " + obj, e); } } JsonCodec();  JsonCodec(boolean indent);  JsonCodec(boolean indent, boolean privateVisible); @Override String encode(Object obj); @Override T decode(String data, Class<T> clazz); @Override byte[] encodeAsBytes(Object obj); @Override T decode(byte[] data, Class<T> clazz); @Override T decode(String data, GenericTypeReference<T> reference); @Override T decode(byte[] data, GenericTypeReference<T> reference); static JsonCodec INSTANCE; }
@Test public void testLeftRight() { LeftRight leftRight = new LeftRight("left", "right"); logger.info("{}", JsonCodec.INSTANCE.encode(leftRight)); }
@Test public void test() { JsonCodec jsonCodec = new JsonCodec(); System.out.println(jsonCodec.encode("123\n345")); }
@Test public void testSet() { Set<String> set = new HashSet<>(); set.add("1"); logger.info("{}", JsonCodec.INSTANCE.encode(set)); }
@Test public void testEnum() { Person person = new Person(Person.SEX.FEMALE); logger.info("{}", JsonCodec.INSTANCE.encode(person)); }