java json-lib.jar
Posted N神3
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java json-lib.jar相关的知识,希望对你有一定的参考价值。
import java.util.ArrayList; import java.util.Date; import java.util.List; import net.sf.json.JSONObject; public class Test { public static void main(String[] args) { Mybean bean = new Test().new Mybean(); bean.setId("001"); bean.setName("银行卡"); bean.setDate(new Date()); List cardNum = new ArrayList(); cardNum.add("农行"); cardNum.add("工行"); cardNum.add("建行"); cardNum.add(new Person("test")); bean.setCardNum(cardNum); JSONObject jsonObject = JSONObject.fromObject(bean); System.out.println(jsonObject); } //内部类 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) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Date getDate() { return date; } public void setDate(Date date) { this.date = date; } public List getCardNum() { return cardNum; } public void setCardNum(List cardNum) { this.cardNum = cardNum; } } }
以上是关于java json-lib.jar的主要内容,如果未能解决你的问题,请参考以下文章
maven 加入json-lib.jar 报错 Missing artifact net.sf.json-lib:json-lib:jar:2.4:compile
关于maven中下载导入json JAR包的问题 Missing artifact net.sf.json-lib:json-lib:jar:2.2.3:compile
Missing artifact net.sf.json-lib:json-lib:jar:2.4错误和Eclipse安装Maven插件错误