JSONObject.fromObject cannot find this method or reports an error


I created the project quickly by springboot and imported springboot json.jar by default.
The JSONObject.fromObject method could not be found.

Solution: add in pom dependency

  <dependency>


        <groupId>net.sf.json-lib</groupId>

        <artifactId>json-lib</artifactId>

        <version>2.4</version>

        <classifier>jdk15</classifier>

        </dependency>

That's it!
Note: Don't change jdk15, save it and wait for the Jar package to download. Re-import

 

supplement:

JSONObject jo = JSONObject.fromObject(map);JSONObject.fromObject 

Convert common java code into json

Guess you like

Origin blog.csdn.net/qq_36090127/article/details/102458990