Package org.kordamp.json
Class JSONObject.Impl
- java.lang.Object
-
- org.kordamp.json.JSONObject.Impl
-
- Enclosing class:
- JSONObject
public static class JSONObject.Impl extends Object
This class is considered private API.
It should only be used for developers extending the capabilities of the library and/or those writing custom JSON Bean/Value processors.
-
-
Constructor Summary
Constructors Constructor Description Impl()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ObjectconvertPropertyValueToArray(String key, Object value, Class targetType, JsonConfig jsonConfig, Map classMap)static CollectionconvertPropertyValueToCollection(String key, Object value, JsonConfig jsonConfig, String name, Map classMap, Class collectionType)static ListconvertPropertyValueToList(String key, Object value, JsonConfig jsonConfig, String name, Map classMap)static JSONObjectdefaultBeanProcessing(Object bean, JsonConfig jsonConfig)static ClassfindTargetClass(String key, Map classMap)Locates a Class associated to a specifi key.
The key may be a regexp.static JSONObjectfromBean(Object bean, JsonConfig jsonConfig)Creates a JSONObject from a POJO.
Supports nested maps, POJOs, and arrays/collections.static JSONObjectfromDynaBean(DynaBean bean, JsonConfig jsonConfig)static JSONObjectfromJSONObject(JSONObject object, JsonConfig jsonConfig)static JSONObjectfromJSONString(JSONString string, JsonConfig jsonConfig)static JSONObjectfromJSONTokener(JSONTokener tokener, JsonConfig jsonConfig)static JSONObjectfromMap(Map map, JsonConfig jsonConfig)static JSONObjectfromString(String str, JsonConfig jsonConfig)static org.kordamp.json.JSONObject.PropertygetProperty(Class beanClass, Object bean, String key, JsonConfig jsonConfig)static booleanisTransient(AnnotatedElement element, JsonConfig jsonConfig)static booleanisTransientField(Field field, JsonConfig jsonConfig)static booleanisTransientField(String name, Class beanClass, JsonConfig jsonConfig)static ObjectmorphPropertyValue(String key, Object value, Class type, Class targetType)static ClassresolveClass(Map classMap, String key, String name, Class type)static voidsetProperty(Object bean, String key, Object value, JsonConfig jsonConfig)Sets a property on the target bean.
Bean may be a Map or a POJO.static voidsetValue(JSONObject jsonObject, String key, Object value, Class type, JsonConfig jsonConfig, boolean bypass)
-
-
-
Method Detail
-
getProperty
public static org.kordamp.json.JSONObject.Property getProperty(Class beanClass, Object bean, String key, JsonConfig jsonConfig) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
-
defaultBeanProcessing
public static JSONObject defaultBeanProcessing(Object bean, JsonConfig jsonConfig)
-
fromBean
public static JSONObject fromBean(Object bean, JsonConfig jsonConfig)
Creates a JSONObject from a POJO.
Supports nested maps, POJOs, and arrays/collections.- Parameters:
bean- An object with POJO conventions- Throws:
JSONException- if the bean can not be converted to a proper JSONObject.
-
fromDynaBean
public static JSONObject fromDynaBean(DynaBean bean, JsonConfig jsonConfig)
-
fromJSONObject
public static JSONObject fromJSONObject(JSONObject object, JsonConfig jsonConfig)
-
fromJSONString
public static JSONObject fromJSONString(JSONString string, JsonConfig jsonConfig)
-
fromJSONTokener
public static JSONObject fromJSONTokener(JSONTokener tokener, JsonConfig jsonConfig)
-
fromMap
public static JSONObject fromMap(Map map, JsonConfig jsonConfig)
-
fromString
public static JSONObject fromString(String str, JsonConfig jsonConfig)
-
convertPropertyValueToArray
public static Object convertPropertyValueToArray(String key, Object value, Class targetType, JsonConfig jsonConfig, Map classMap)
-
convertPropertyValueToList
public static List convertPropertyValueToList(String key, Object value, JsonConfig jsonConfig, String name, Map classMap)
-
convertPropertyValueToCollection
public static Collection convertPropertyValueToCollection(String key, Object value, JsonConfig jsonConfig, String name, Map classMap, Class collectionType)
-
findTargetClass
public static Class findTargetClass(String key, Map classMap)
Locates a Class associated to a specifi key.
The key may be a regexp.
-
isTransientField
public static boolean isTransientField(String name, Class beanClass, JsonConfig jsonConfig)
-
isTransientField
public static boolean isTransientField(Field field, JsonConfig jsonConfig)
-
isTransient
public static boolean isTransient(AnnotatedElement element, JsonConfig jsonConfig)
-
morphPropertyValue
public static Object morphPropertyValue(String key, Object value, Class type, Class targetType)
-
setProperty
public static void setProperty(Object bean, String key, Object value, JsonConfig jsonConfig) throws Exception
Sets a property on the target bean.
Bean may be a Map or a POJO.- Throws:
Exception
-
setValue
public static void setValue(JSONObject jsonObject, String key, Object value, Class type, JsonConfig jsonConfig, boolean bypass)
-
-