Java Json-lib.jar

Source: Internet
Author: User

import java.util.arraylist;import;import java.util.List; Import Net.sf.json.jsonobject;public class Test {public static void main (string[] args) {Mybean bean = new Test (). New Mybe An (); Bean.setid ("001"); Bean.setname ("bank card"); Bean.setdate (new Date ()); List cardnum = new ArrayList (), Cardnum.add ("abc"), Cardnum.add ("ICBC"), Cardnum.add ("CCB"), Cardnum.add (New person ("test") ); Bean.setcardnum (Cardnum); Jsonobject jsonobject = Jsonobject.fromobject (bean); System.out.println (jsonobject);} Internal class public class Mybean{private string Id;private string name;private Date date;private List cardnum;public string GetId ( ) {return ID;} public void SetId (String id) { = ID;} Public String GetName () {return name;} public void SetName (String name) { = name;} Public Date getDate () {return date;} public void SetDate (date date) { = date;} Public List Getcardnum () {return cardnum;} public void Setcardnum (List cardnum) {this.cardnum = Cardnum;}}} 


Java Json-lib.jar

Related Article

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: 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.