Import json related packages through maven's pom file
<!-- jsion and java conversion -->
<dependency><groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.6</version>
</dependency>
The imported package is as follows
Note: When using JSONArray, select the net.sf.json package instead of the other two, as shown below
If you make a wrong choice when using JSONArray, you will find that fromObject(pros).toString()) cannot be found (pros is my own parameter, which means Arraylist, you can replace it with bean or something according to your own needs), especially pit, Of course, when using JSONString or others, you should also pay attention to the use. I have been pitted for this all night. I always thought it was a small jar package, and finally found that it was a mistake.
I am converting ArrayList to json object
Then the java object can be used to convert the json object, and it can also be converted between each other.
Please advise.