Java Object to Json toJSON(T obj)

Here you can find the source of toJSON(T obj)

Description

to JSON

License

Artistic License

Declaration

public static <T> String toJSON(T obj) 

Method Source Code

//package com.java2s;
//License from project: Artistic License 

public class Main {
    public static final com.fasterxml.jackson.databind.ObjectMapper mapper = new com.fasterxml.jackson.databind.ObjectMapper();

    public static <T> String toJSON(T obj) {
        try {//from  www .j a v a 2 s  . c  om
            return mapper.writeValueAsString(obj);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. toJson(Object object)
  2. toJson(Object object)
  3. toJson(Object object)
  4. toJson(Object value)
  5. toJSON(T obj)
  6. toJSON(T valueType)
  7. toJsonString(Object obj)
  8. toJsonString(Object obj)
  9. toJSONString(Object object, boolean camelCaseToLowerCaseWithUnderscores)