@@ -3472,12 +3472,15 @@ private Type[] getMapTypes(Type type) {
34723472 * of the given class. It supports basic data types including int, double, float,
34733473 * long, and boolean (as well as their boxed counterparts). The class must have a
34743474 * no-argument constructor, and the field names in the class must match the keys
3475- * in the JSON string.
3475+ * in the JSON string. Static fields are ignored; see {@link #fromJson(Class)} for
3476+ * how the remaining fields are bound.
34763477 *
34773478 * @param <T> the type of the object to return
34783479 * @param jsonString json in string format
34793480 * @param clazz the class of the object to be returned
34803481 * @return an instance of Object T with fields populated from the JSON string
3482+ * @throws JSONException if jsonString is not valid JSON, or if it cannot be bound to clazz
3483+ * as described in {@link #fromJson(Class)}
34813484 */
34823485 public static <T > T fromJson (String jsonString , Class <T > clazz ) {
34833486 JSONObject jsonObject = new JSONObject (jsonString );
@@ -3493,15 +3496,20 @@ public static <T> T fromJson(String jsonString, Class<T> clazz) {
34933496 * The target class must have a no-argument constructor, and its field names must match
34943497 * the keys in the JSON string. Static fields are ignored.
34953498 *
3496- * <p><strong>Note:</strong> Only classes that are explicitly supported and registered within
3497- * the {@code JSONObject} context can be deserialized. If the provided class is not among those,
3498- * this method will not be able to deserialize it. This ensures that only a limited and
3499- * controlled set of types can be instantiated from JSON for safety and predictability.
3499+ * <p><strong>Note:</strong> binding is driven by the keys present in the JSON, not by
3500+ * how the fields are declared. Every non-static field declared by the class is written
3501+ * when its name matches a key, including {@code private} and {@code transient} fields,
3502+ * and field access is widened with
3503+ * {@link java.lang.reflect.Field#setAccessible(boolean)}. {@link JSONPropertyIgnore}
3504+ * only suppresses the bean to JSONObject direction, so it does not keep a field from
3505+ * being populated here. JSON coming from an untrusted source should therefore be
3506+ * validated, or reduced to the expected keys, before it is handed to this method.
35003507 *
35013508 * @param clazz the class of the object to be returned
35023509 * @param <T> the type of the object
35033510 * @return an instance of type {@code T} with fields populated from the JSON string
3504- * @throws IllegalArgumentException if the class is not supported for deserialization
3511+ * @throws JSONException if the class has no accessible no-argument constructor, or if a
3512+ * field cannot be instantiated or set
35053513 */
35063514 @ SuppressWarnings ("unchecked" )
35073515 public <T > T fromJson (Class <T > clazz ) {
0 commit comments