JSONObject.parseArray
时间: 2024-03-22 09:14:07 浏览: 79
JSONObject.parseArray is a method in the JSON library for Java that converts a JSON string into a List of Java objects. It takes two parameters: a String representing the JSON array, and a Class representing the type of object that the array should be parsed into.
For example, if we have a JSON array of strings:
```json
["apple", "banana", "orange"]
```
We can parse it into a List of String objects using the following code:
```java
String jsonArray = "[\"apple\", \"banana\", \"orange\"]";
List<String> fruits = JSONObject.parseArray(jsonArray, String.class);
```
The resulting List would contain the following elements:
```java
["apple", "banana", "orange"]
```
This method can also be used to parse JSON arrays of more complex objects, such as JSON objects or custom Java objects.
阅读全文