Class JSONEncoder<T>
- java.lang.Object
-
- org.epics.archiverappliance.utils.ui.JSONEncoder<T>
-
public class JSONEncoder<T> extends Object
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 Type Method Description org.json.simple.JSONObject
encode(T obj)
void
encodeAndAdd(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..void
encodeAndPrint(T obj, PrintWriter out)
static <T> JSONEncoder<T>
getEncoder(Class<T> clazz)
-
-
-
Method Detail
-
getEncoder
public static <T> JSONEncoder<T> getEncoder(Class<T> clazz) throws IntrospectionException
- 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
-
-