Class JSONEncoder<T>
java.lang.Object
org.epics.archiverappliance.utils.ui.JSONEncoder<T>
Generate something that converts a POJO into JSON using bean introspection.
Underlying framework is still json-simple.
This has a giant switch statement that does things based on types; so please add unit tests as part of adding new fields to objects that use JSONEncoder.
- Author:
- mshankar
-
Method Summary
Modifier and TypeMethodDescriptionorg.json.simple.JSONObjectvoidencodeAndAdd(T obj, org.json.simple.JSONArray arrayOfObjs) Encode the object and add it to this array Dealing with JSON generates a lot of suppress warnings from raw types..voidencodeAndPrint(T obj, PrintWriter out) static <T> JSONEncoder<T> getEncoder(Class<T> clazz)
-
Method Details
-
getEncoder
- Throws:
IntrospectionException
-
encode
public org.json.simple.JSONObject encode(T obj) throws IllegalAccessException, InvocationTargetException -
encodeAndAdd
public void encodeAndAdd(T obj, org.json.simple.JSONArray arrayOfObjs) throws IllegalAccessException, InvocationTargetException Encode the object and add it to this array Dealing with JSON generates a lot of suppress warnings from raw types..- Parameters:
obj- TarrayOfObjs- JSONArray- Throws:
IllegalAccessException-InvocationTargetException-
-
encodeAndPrint
public void encodeAndPrint(T obj, PrintWriter out) throws IllegalAccessException, InvocationTargetException
-