1. 程式人生 > >java轉換json需要匯入的jar包,org/apache/commons/lang/exception/NestableRuntimeException

java轉換json需要匯入的jar包,org/apache/commons/lang/exception/NestableRuntimeException

commons-beanutils-1.8.0.jar不加這個包
java.lang.NoClassDefFoundError: org/apache/commons/beanutils/DynaBean
commons-collections.jar 不加這個包
java.lang.NoClassDefFoundError: org/apache/commons/collections/map/ListOrderedMap
commons-lang-2.4.jar不加這個包
java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
commons-logging-1.1.1.jar不加這個包
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
ezmorph-1.0.4.jar不加這個包
java.lang.NoClassDefFoundError: net/sf/ezmorph/Morpher
json-lib-2.3-jdk15.jar不加這個包
java.lang.NoClassDefFoundError: net/sf/json/JSONObject
相應jar包可到網上下載,也可以用下面提供的!

例項:
import java.util.ArrayList;
import java.util.List;

import net.sf.json.JSONArray;

public class JsonTest {

/**
* @param args
*/
public static void main(String[] args) throws Exception{
boolean[] boolArray = new boolean[]{true,false,true};
JSONArray jsonArray = JSONArray.fromObject( boolArray );
System.out.println( jsonArray );

List list = new ArrayList();
list.add( "first" );
list.add( "second" );
JSONArray jsonArray2 = JSONArray.fromObject( list );
System.out.println( jsonArray2 );
}
}