Java Object to Json writeValueAsString(Object obj)

Here you can find the source of writeValueAsString(Object obj)

Description

write Value As String

License

Apache License

Declaration

public static String writeValueAsString(Object obj) 

Method Source Code

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

import com.fasterxml.jackson.databind.ObjectMapper;

public class Main {
    static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

    public static String writeValueAsString(Object obj) {
        try {//from   ww w  .  ja  v a 2 s .  co  m
            return OBJECT_MAPPER.writeValueAsString(obj);
        } catch (Exception e) {
            System.err.println(e.getMessage());
            return null;
        }
    }
}

Related

  1. writeJSON(HashMap data)
  2. writeValueAsBytes(Object value)
  3. writeValueAsIndentString(Object value)
  4. writeValueAsString(Object o)
  5. writeValueAsString(Object obj)