Java Object to Json toJson(Object object)

Here you can find the source of toJson(Object object)

Description

to Json

License

Apache License

Declaration

public static String toJson(Object object) 

Method Source Code


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

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class Main {
    public static String toJson(Object object) {

        try {/*w w  w.ja  v a  2  s. co  m*/
            return new ObjectMapper().writeValueAsString(object);
        } catch (JsonProcessingException e) {
            return null;
        }
    }
}

Related

  1. toJson(Object o)
  2. toJson(Object o)
  3. toJSON(Object obj)
  4. toJSON(Object obj)
  5. toJson(Object obj)
  6. toJson(Object object)
  7. toJson(Object object)
  8. toJson(Object value)
  9. toJSON(T obj)