Add the following configuration information in the MAVEN configuration file Pom.xml:Dependency> groupId>Net.sf.json-libgroupId> Artifactid>Json-libArtifactid> version>2.4version> classifier>Jdk15classifier>Dependency>Note:In the MAVEN
1. from object to stringTo construct a jsonobject or Jsonarray object with object, then call its ToString () method to(1) Example one1 book Book=new book ();2 Book.setname ("Java");3 Book.setprice (52.3f);4 Jsonobject object=jsonobject.fromobject
jsonobject This object can be seen as a mapTwo methods of construction:Jsonobject Jo = new Jsonobject ();jsonobject Jo = Jsonobject.fromobject ( requires a Map object or JavaBean object here ) ;Convert to JSON string: string json = jo.tostring ();
Dependent jar:Commons-beanutils-1.9.3.jar?Commons-collections-3.1.jarCommons-lang-2.4.jarCommons-logging-1.2.jarEzmorph-1.0.6.jarJson-lib-2.4-jdk15.jarTest procedure:1, Person.java: import java.util.List; /** * Created by Administrator to 2017/5
Arrays and lists, collection, etc. are parsed with Jsonarray
Boolean[] Boolarray =New Boolean[]{true,false,true}; Jsonarray Jsonarray=Jsonarray.fromobject (Boolarray); System.out.println (Jsonarray); //prints [true,false,true]List List
The package used:Commons-beanutils.jarCommons-collections-3.1.jarCommons-lang.jarCommons-logging-1.1.3.jarEzmorph-1.0.jarJson-lib-2.2.2-jdk15.jarLet's look at the interaction between JSON and string.User.java User Object Package test; Public class
Android cannot use Json-lib-2.4-jdk15.jar, to use its own Org.json pack
Use the following methods:
public static int getplatforminfolist (String json){int count=0;try {Jsonarray jarr=new Jsonarray (JSON);int length = Jarr.length ();for (int i =
JSON lib 2.4 required Jar pack
The official statement is that at least the following packages are required
Jakarta Commons-lang 2.5 Jakarta Commons-beanutils 1.8.0 Jakarta commons-collections 3.2.1 Jakarta commons-logging 1.1.1 E Zmorph 1.0.6
Recently done some performance optimization work, in the selection of JSON class library, found in addition to the commonly used json-lib, there is also known as the fastest performance of the JSON processor Jackson, and then used the newly learned
This article transferred from: http://blog.csdn.net/yangbobo1992/article/details/83507651. from object to stringTo construct a jsonobject or Jsonarray object with object, then call its ToString () method to(1) Example one1 book Book=new Book (), 2
Net. SF. JSON format date
Similar to other types
Date is before formatting createdate ": {" date ": 4," day ": 2," hours ": 17," Minutes ": 18," month ": 7, "seconds": 34, "Time": 1249377514000, "timezoneoffset":-480, "year": 109}
Dependent jar:Commons-beanutils-1.9.3.jar?Commons-collections-3.1.jarCommons-lang-2.4.jarCommons-logging-1.2.jarEzmorph-1.0.6.jarJson-lib-2.4-jdk15.jarDirectly on the program1, Person.java: import java.util.List; /** * Created by Administrator
Second, the list and JSON string of the mutual transferlist--"JSON string Public Static voidListtojson () {Student stu=NewStudent (); Stu.setname ("JSON"); Stu.setage ("23"); Stu.setaddress ("Haidian District, Beijing"); List lists=NewArraylist();
1. from object to stringTo construct a jsonobject or Jsonarray object with object, then call its ToString () method to(1) Example one1 book book=new Book (); 2 book.setname ("Java"); 3 book.setprice (52.3f); 4 jsonobject
This problem is easy to use with Hibernate, mainly due to the cascading relationship of Pojo class attributes. For example, employees and departments, which have departmental attributes in the employee table, and a collection of employees in the
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:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.