Monday 7 July 2008

JSON : Array List <> JSON

Converting method between array List and JSON

You need some jar files.
1. json-lib-2.2.2-jdk15.jar
2. commons-beanutils.jar
3. commons-lang.jar
4. commons-collections.jar
5. commons-logging.jar
6. ezmorph-1.0.4.jar

Please set classpath those jar files.
And here is sample source to change from ArrayList to JSON.


import java.util.ArrayList;
import java.util.List;

import net.sf.json.JSONArray;

public class testA {

/**
* @param args
*/
public static void main(String[] args) {

List mybeanList = new ArrayList();
mybeanList.add("S");
mybeanList.add("b");

JSONArray jsonA = JSONArray.fromObject(mybeanList);
System.out.println(jsonA);
}

}

2 comments:

Anonymous said...

I think the admin of this website is truly working hard in favor of his site, since here every stuff
is quality based material.

Feel free to surf to my web blog graduate certificate
My website - graduate certificate

Anonymous said...

Valare valareaa shariyaanu..