Package org.eclipse.jetty.util.ajax
Class JSONPojoConvertor
java.lang.Object
org.eclipse.jetty.util.ajax.JSONPojoConvertor
- All Implemented Interfaces:
JSON.Convertor
Converts POJOs to JSON and vice versa.
The key differences with respect to JSONObjectConvertor
are:
- returns the actual object from Convertor.fromJSON (JSONObjectConverter returns a Map)
- the getters/setters are resolved at initialization (JSONObjectConverter resolves it at runtime)
- correctly sets the number fields
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static class
-
Field Summary
-
Constructor Summary
ConstructorDescriptionJSONPojoConvertor
(Class<?> pojoClass) JSONPojoConvertor
(Class<?> pojoClass, boolean fromJSON) JSONPojoConvertor
(Class<?> pojoClass, String[] excluded) JSONPojoConvertor
(Class<?> pojoClass, Set<String> excluded) JSONPojoConvertor
(Class<?> pojoClass, Set<String> excluded, boolean fromJSON) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected void
static JSONPojoConvertor.NumberType
getNumberType
(Class<?> clazz) protected JSONPojoConvertor.Setter
protected boolean
includeField
(String name, Method m) protected void
init()
void
toJSON
(Object obj, JSON.Output out)
-
Field Details
-
_fromJSON
protected boolean _fromJSON -
_pojoClass
-
_getters
-
_setters
-
_excluded
-
-
Constructor Details
-
JSONPojoConvertor
- Parameters:
pojoClass
- The class to convert
-
JSONPojoConvertor
- Parameters:
pojoClass
- The class to convertfromJSON
- If true, add a class field to the JSON
-
JSONPojoConvertor
- Parameters:
pojoClass
- The class to convertexcluded
- The fields to exclude
-
JSONPojoConvertor
- Parameters:
pojoClass
- The class to convertexcluded
- The fields to exclude
-
JSONPojoConvertor
- Parameters:
pojoClass
- The class to convertexcluded
- The fields to excludefromJSON
- If true, add a class field to the JSON
-
-
Method Details
-
getNumberType
-
init
protected void init() -
addGetter
-
addSetter
-
getSetter
-
includeField
-
fromJSON
- Specified by:
fromJSON
in interfaceJSON.Convertor
-
toJSON
- Specified by:
toJSON
in interfaceJSON.Convertor
-