-2

Cn anyone show a example of generating a JSOn from a bean class using JSON-LIB? I am not able to find a example to understand this.

Thanks

pihu
  • 93
  • 1
  • 11

1 Answers1

2

How about?

MyBean mb = new MyBean();
JSON json = JSONObject.fromObject(mb);
Pablo Santa Cruz
  • 176,835
  • 32
  • 241
  • 292
  • If the bean has arrays ,list ,map defined how will this work? – pihu Oct 28 '11 at 14:19
  • I am getting the following error after trying this Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException ,i have simple employee bean class used json-lib-2.4-jdk15.jar ,let me know what is wrong – pihu Oct 31 '11 at 08:39