/** * Construct a JSONObject from an Object using bean getters. It reflects on all of the public * methods of the object. For each of the methods with no parameters and a name starting with * <code>"get"</code> or <code>"is"</code> followed by an uppercase letter, the method is invoked, * and a key and the value returned from the getter method are put into the new JSONObject. * * <p>The key is formed by removing the <code>"get"</code> or <code>"is"</code> prefix. If the * second remaining character is not upper case, then the first character is converted to lower * case. * * @param bean An object that has getter methods that should be used to make a JSONObject. * @param includeSuperClass If true, include the super class properties. */ public JSONObject(Object bean, boolean includeSuperClass) { this(); populateInternalMap(bean, includeSuperClass); }
/** * Construct a JSONObject from an Object using bean getters. It reflects on all of the public * methods of the object. For each of the methods with no parameters and a name starting with * <code>"get"</code> or <code>"is"</code> followed by an uppercase letter, the method is invoked, * and a key and the value returned from the getter method are put into the new JSONObject. * * <p>The key is formed by removing the <code>"get"</code> or <code>"is"</code> prefix. If the * second remaining character is not upper case, then the first character is converted to lower * case. * * <p>For example, if an object has a method named <code>"getName"</code>, and if the result of * calling <code>object.getName()</code> is <code>"Larry Fine"</code>, then the JSONObject will * contain <code>"name": "Larry Fine"</code>. * * @param bean An object that has getter methods that should be used to make a JSONObject. */ public JSONObject(Object bean) { this(); populateInternalMap(bean, false); }