Java.lang.noclassdeffounderror Error Resolution (for Jsonarray and jsonobject use) __42286

Source: Internet
Author: User

Today I want to convert a string type to a JSON array format, but always report java.lang.noclassdeffounderror errors, and finally I solve the problem, the following steps to solve

First, the introduction of the package

It is not enough to introduce a json-lib jar package for the program to be introduced, and the following additional packages must be introduced

1, Commons-beanutils.jar

2, Commons-collections-3.2.jar

3, Commons-lang-2.5.jar

4, Commons-logging-1.1.1.jar

5, Ezmorph-1.0.4.jar

6, Json-lib-2.4-jdk15.jar

The introduction of these packages to ensure the normal operation of abbreviated code

Ii. specific applications (use of Jsonarray)

Package zyj.com;

Import java.util.List;
Import Net.sf.json.JSONArray;

public class Jsontest {public
	static void Main (string[] args) {
		Jsonarray jsonobject = Jsonarray.fromobject ("[{] Name ': ' Huangbiao ', ' age ': 15},{' name ': ' Liumei ', ' Age ':}] ';
		List<studentpo> student=jsonobject.tolist (jsonobject,studentpo.class);
		for (Studentpo studentpo:student) {
			System.out.println (studentpo.getname () + ";" +studentpo.getage ());}}
Results:
Huangbiao;15
liumei;14
Iii. the difference between Jsonarray and Jsonobject

Jsonobject is an object that is wrapped up in {};

Jsonarray is an array of [] wrapped;



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.