JSONObject.parseObject
时间: 2024-03-22 19:15:00 浏览: 96
jsonObject
JSONObject.parseObject() is a method in the Java programming language that converts a JSON string into a Java object. It is part of the JSON library provided by Alibaba Group, and is commonly used in Java-based web applications to handle data in JSON format.
The method takes two parameters: the JSON string to be parsed, and the class of the Java object that the JSON data will be converted to. The class can be specified as a Class object or as a String representing the fully qualified class name.
Here is an example of using the JSONObject.parseObject() method to parse a JSON string into a Java object:
```
String jsonString = "{\"name\": \"John\", \"age\": 30}";
Person person = JSONObject.parseObject(jsonString, Person.class);
```
In this example, the JSON string is `{"name": "John", "age": 30}`. The `Person` class is specified as the target class for the JSON data. The `JSONObject.parseObject()` method converts the JSON data into a `Person` object, which can then be used in the application.
阅读全文