Java Object to Json writeValueAsBytes(Object value)

Here you can find the source of writeValueAsBytes(Object value)

Description

write Value As Bytes

License

Open Source License

Declaration

public static byte[] writeValueAsBytes(Object value) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import com.fasterxml.jackson.core.JsonProcessingException;

import com.fasterxml.jackson.databind.ObjectMapper;

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

    public static byte[] writeValueAsBytes(Object value) {
        try {/*from  w  w w .  j  a va 2  s. co  m*/
            return OBJECT_MAPPER.writeValueAsBytes(value);
        } catch (JsonProcessingException e) {
            throw new IllegalStateException(e);
        }
    }
}

Related

  1. toJsonString(Object obj)
  2. toJsonString(Object obj)
  3. toJSONString(Object object, boolean camelCaseToLowerCaseWithUnderscores)
  4. toJsonString(T value)
  5. writeJSON(HashMap data)
  6. writeValueAsIndentString(Object value)
  7. writeValueAsString(Object o)
  8. writeValueAsString(Object obj)
  9. writeValueAsString(Object obj)