mirror of
https://github.com/stleary/JSON-java.git
synced 2026-01-24 00:03:17 -05:00
Updating docs
This commit is contained in:
@@ -3376,13 +3376,20 @@ public class JSONObject {
|
|||||||
* Deserializes a JSON string into an instance of the specified class.
|
* Deserializes a JSON string into an instance of the specified class.
|
||||||
*
|
*
|
||||||
* <p>This method attempts to map JSON key-value pairs to the corresponding fields
|
* <p>This method attempts to map JSON key-value pairs to the corresponding fields
|
||||||
* of the given class. It supports basic data types including int, double, float,
|
* of the given class. It supports basic data types including {@code int}, {@code double},
|
||||||
* long, and boolean (as well as their boxed counterparts). The class must have a
|
* {@code float}, {@code long}, and {@code boolean}, as well as their boxed counterparts.
|
||||||
* no-argument constructor, and the field names in the class must match the keys
|
* The target class must have a no-argument constructor, and its field names must match
|
||||||
* in the JSON string.
|
* the keys in the JSON string.
|
||||||
|
*
|
||||||
|
* <p><strong>Note:</strong> Only classes that are explicitly supported and registered within
|
||||||
|
* the {@code JSONObject} context can be deserialized. If the provided class is not among those,
|
||||||
|
* this method will not be able to deserialize it. This ensures that only a limited and
|
||||||
|
* controlled set of types can be instantiated from JSON for safety and predictability.
|
||||||
*
|
*
|
||||||
* @param clazz the class of the object to be returned
|
* @param clazz the class of the object to be returned
|
||||||
* @return an instance of type T with fields populated from the JSON string
|
* @param <T> the type of the object
|
||||||
|
* @return an instance of type {@code T} with fields populated from the JSON string
|
||||||
|
* @throws IllegalArgumentException if the class is not supported for deserialization
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T> T fromJson(Class<T> clazz) {
|
public <T> T fromJson(Class<T> clazz) {
|
||||||
|
|||||||
Reference in New Issue
Block a user