Jsonarray.fromobject does not perform and does not answer the problem

Source: Internet
Author: User

Today, when writing Javaweb project, we need to transmit JSON format data to the foreground, and use a series of packages such as Json-lib-2.4-jdk15.jar, however, the following conditions appear:

Citybean is a javabean, we see that the console only prints out the contents of the list, and the following two are not able to print, this shows that the program executes to JSON.Array.fromObject () when the termination, and the console did not report any errors, and no exception thrown, Particularly strange.

The following is a package for JSON import:

First of all, the number of packages is correct, and all I downloaded from the official website, are the latest version, so at first I did not focus on the jar package.

Later saw on the Internet that the list of JavaBean contains other entity attributes, printed out is a memory value, in the process of converting the JSON exception, the entity attributes converted to a string to repopulate, so I rewrite the ToString () method in Citybean:

Unfortunately Jsonarray.fromobject () still does not execute ...

Later wrote a test with JUnit debugging a bit, finally reported abnormal

I can't find the class under Lang???? I have imported the Lang package clearly.

It is said that Tomcat is looking for the jar in its own Lib directory, and if the jar package is not stored in the Tomcat Lib directory, it will not be found. But I still reported the same mistake after I put it in.

Finally, I finally found that I import is Commons-lang3-3.7.jar, and the program needs is Commons-lang jar package, later went to the official website to see the previous version, sure enough 2.x packet Lang behind not immediately followed by the number, the same commons-collections4-4.2.jar should also be replaced by The previous version.

Demo by:

Normal execution of the program:

Jsonarray.fromobject does not perform and does not answer the problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.