Package org.xipki.ca.api.mgmt
Class CaJson
- java.lang.Object
-
- org.xipki.ca.api.mgmt.CaJson
-
public class CaJson extends Object
JSON util class for CA- Author:
- Lijun Liao (xipki)
-
-
Constructor Summary
Constructors Constructor Description CaJson()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.fasterxml.jackson.databind.ObjectMappernewDefaultObjectMapper()static <T> TparseObject(byte[] json, Class<T> classOfT)static <T> TparseObject(File jsonFile, Class<T> classOfT)static <T> TparseObject(InputStream jsonInputStream, Class<T> classOfT)Deserialize the object from the input stream.static <T> TparseObject(String json, Class<T> classOfT)static <T> TparseObject(Path jsonFilePath, Class<T> classOfT)static <T> TparseObjectAndClose(InputStream jsonInputStream, Class<T> classOfT)Deserialize the object from the input stream and closes the inputstream.static StringtoJson(Object obj)static byte[]toJSONBytes(Object obj)static StringtoPrettyJson(Object obj)static voidwriteJSON(Object object, OutputStream outputStream)Serialize the object to the output stream.static voidwriteJSONAndClose(Object object, OutputStream outputStream)Serialize the object to the output stream.static voidwritePrettyJSON(Object object, OutputStream outputStream)Serialize the object in pretty format to the output stream.static voidwritePrettyJSONAndClose(Object object, OutputStream outputStream)Serialize the object in pretty format to the output stream.
-
-
-
Method Detail
-
newDefaultObjectMapper
public static com.fasterxml.jackson.databind.ObjectMapper newDefaultObjectMapper()
-
parseObject
public static <T> T parseObject(byte[] json, Class<T> classOfT)
-
parseObject
public static <T> T parseObject(Path jsonFilePath, Class<T> classOfT) throws IOException
- Throws:
IOException
-
parseObject
public static <T> T parseObject(File jsonFile, Class<T> classOfT) throws IOException
- Throws:
IOException
-
parseObject
public static <T> T parseObject(InputStream jsonInputStream, Class<T> classOfT) throws IOException
Deserialize the object from the input stream. The specified stream remains open after this method returns.- Type Parameters:
T- the object type of serialized object.- Parameters:
jsonInputStream- the input stream containing the serialized object.classOfT- the class of deserialized object.- Returns:
- the serialized object
- Throws:
IOException- if IO error occurs while reading the stream.
-
parseObjectAndClose
public static <T> T parseObjectAndClose(InputStream jsonInputStream, Class<T> classOfT) throws IOException
Deserialize the object from the input stream and closes the inputstream. The specified stream is closed after this method returns.- Type Parameters:
T- the object type of serialized object.- Parameters:
jsonInputStream- the input stream containing the serialized object.classOfT- the class of deserialized object.- Returns:
- the serialized object
- Throws:
IOException- if IO error occurs while reading the stream.
-
toJSONBytes
public static byte[] toJSONBytes(Object obj)
-
writeJSON
public static void writeJSON(Object object, OutputStream outputStream) throws IOException
Serialize the object to the output stream. The specified stream remains open after this method returns.- Parameters:
object- object to be serialized.outputStream- output stream to which the serialized object is written.- Throws:
IOException- if IO error occurs while writting to the stream.
-
writeJSONAndClose
public static void writeJSONAndClose(Object object, OutputStream outputStream) throws IOException
Serialize the object to the output stream. The specified stream is closed after this method returns.- Parameters:
object- object to be serialized.outputStream- output stream to which the serialized object is written.- Throws:
IOException- if IO error occurs while writting to the stream.
-
writePrettyJSON
public static void writePrettyJSON(Object object, OutputStream outputStream) throws IOException
Serialize the object in pretty format to the output stream. The specified stream remains open after this method returns.- Parameters:
object- object to be serialized.outputStream- output stream to which the serialized object is written.- Throws:
IOException- if IO error occurs while writting to the stream.
-
writePrettyJSONAndClose
public static void writePrettyJSONAndClose(Object object, OutputStream outputStream) throws IOException
Serialize the object in pretty format to the output stream. The specified stream is closed after this method returns.- Parameters:
object- object to be serialized.outputStream- output stream to which the serialized object is written.- Throws:
IOException- if IO error occurs while writting to the stream.
-
-