{
Method[] methods = object.getClass().getMethods();
List<String> transientFields = getTransientFields(object.getClass());
JsonValue jsonRootValue = new ObjectValue();
for (Method method : methods)
{
String methodName = method.getName();
/*
* Method must be as follow:
* 1. Name starts from "get" plus at least one character or starts from
* "is" plus at least one more character and return boolean type
* 2. Must be without parameters
* 3. Must not be in list of skipped methods
*/
String key = null;
if (!SKIP_METHODS.contains(methodName) && method.getParameterTypes().length == 0)
{
if (methodName.startsWith("get") && methodName.length() > 3)
{
key = methodName.substring(3);
}
else if (methodName.startsWith("is") && methodName.length() > 2
&& (method.getReturnType() == Boolean.class || method.getReturnType() == boolean.class))
{
key = methodName.substring(2);
}
}
if (key != null)
{
// First letter of key to lower case.
key = (key.length() > 1) ? Character.toLowerCase(key.charAt(0)) + key.substring(1) : key.toLowerCase();
// Check is this field in list of transient field.
if (!transientFields.contains(key))
{
try
{
// Get result of invoke method get...
Object invokeResult = method.invoke(object, new Object[0]);
if (JsonUtils.getType(invokeResult) != null)
{
jsonRootValue.addElement(key, createJsonValue(invokeResult));
}
else
{
jsonRootValue.addElement(key, createJsonObject(invokeResult));
}
}
catch (InvocationTargetException e)
{