first, JSON introduction
JSON (JavaScript Object notation), similar to XML, is a data interchange format, such as Java, which produces a data that wants to be given to JavaScript, and uses JSON in addition to XML;
The advantage of JSON over XML is that it is simple to exp
Lin Bingwen Evankaka original works. Reprint please specify the source Http://blog.csdn.net/evankakaAbsrtact: This paper mainly discusses the principle and process of memory mapping in Java, compares with the traditional IO, and finally, illustrates the result with an example.What is memory-mapped IO and memory-mapped files in Java? The memory-mapped file is very special, it allows the
mappings are decoded or parsed from the left to the right, and the mapped entities are encoded from right to left.
JSON
Java
String
Java.lang.String
Number
Java.lang.Number
True|false
Ava.lang.Boolean
Null
Null
Array
Java.util.List
Object
Java.util.Map
Alth
object and assign the HashMap object to TreeMap.New TREEMAP (map);Sorting by key value is simple, but because the key value is unique, cannot be duplicated, all, in the actual process may be used to sort value value;Sort Value values: (Descending)//declaring HashMap objectsmapNewHashmap();//Convert a Map collection to a list collectionlistNewArraylist(Map.entrys
Gson-google produced by the JSON processing tools, online praise blockbuster, first to learn.Let's start by listing one of the reviews found online:
Gson is currently the most fully functional JSON parsing artifact, Gson was originally developed by Google in response to Google's internal needs, but has been used by many companies or users since the first edition was released in May 2008. The applic
Net.sf.json.JSONObject provides us with a Tobean method for converting to Java objects, which is much more powerful, with the use of the JDK's reflection mechanism as a simple helper tool, some data types need to be converted and scaled as needed. You can handle long and date types here.only supports the processing of a single Jsonobject object, for complex JSON objects, such as jsonarray arrays, consider t
During the import, we encountered the problem of converting the map object into a javabean object. That is to say, we do not know the internal field arrangement of the javabean object. We only know that the map key represents the field name of the javabean object, value indicates the value.
Now we need a conversion tool. It's universal!
First, let's look at the method for converting JavaBean to
The use of Json-lib and Org.json is almost the same, and I have summed up the difference with two points:Two kinds of packages1. Convert list collection to JSON methodList List = new ArrayList (), List.add ("first"), List.add ("second"); Jsonarray jsonArray2 = jsonarray.fromobject (list);2:map
First,JSON (JavaScript Object Notation) is a simple data format that is lighter than XML. JSON is constructed in two structures:1, the collection of "name/value" pairs (A collection of name/value pairs). In different languages, it is understood as objects (object), record (record), structure (struct), Dictionary (dictionary), hash table (hash table), keyed list (keyed list), or associative array (associativ
When doing the import, encountered the need to convert the map object into a javabean problem, that is, not clear javabean internal field arrangement, only know that the map key represents the JavaBean field name, value represents values.Now it's time to use a conversion tool. It's a universal, oh!Let's start by looking at how JavaBean transforms into a
= { 1, 2, 3};
Set set = new HashSet (Arrays.aslist (a));
5.map of the relevant operation.
Map map = new HashMap ();
Map.put ("1", "a");
Map.put (' 2 ', ' B ');
Map.put (' 3 ', ' C ');
SYSTEM.OUT.PRINTLN (map);
All values are output
System.out.println (Ma
contents of the curly brace wrapped {}, the data structure is {key1:value1, key2:value2, ...} key-value pair structure. In an object-oriented language, key is the property of the object, and value is the corresponding values. Key names can be represented using integers and strings. The type of the value can be any type. Array: The array in JS is square brackets [] wrapped content, data structure for ["Java", "JavaScript", "VB", ...] index structure.
Reference Address: http://blog.sina.com.cn/s/blog_5920510a01011vu8.htmlJsonlib Classic article: http://json-lib.sourceforge.net/xref-test/net/sf/json/TestJSONObject.htmlIntroduce the appropriate packageJson-lib-2.2-jdk15.jarImport Net.sf.json.JSONArray;Import Net.sf.json.JSONObject;1.//Convert the list of Java objects
Map InterfaceThe Map collection stores data in a key-value pair (Key-value) where the key cannot be duplicated and the value can be duplicated.Common classes are HashMap, TreeMap and propertiesHashMap classIf, now I have a collection that stores a batch of WiFi names and passwords, now requires a quick name to find the password. Such a requirement is very difficult to implement with the list collection, and
and collection have identical interfaces.3, List, you can use the Get () method to remove one element at a time. Use numbers to select one of a bunch of objects, get (0) .... (Add/get)4, generally use ArrayList. Use LinkedList to construct stack stacks, queue queues.5, map with put (K,V)/get (k), you can also use ContainsKey ()/containsvalue () to check if it contains a key/value.HashMap will use the object's hashcode to quickly find the key.6, the e
Gson This Java class library converts Java objects to JSON or converts JSON strings into an equal Java object. Gson supports arbitrary complex Java objects including objects that have no source code.Other
JavaWrite and write a row
java specifies encoding to read and write filesSmall white
Transformers 4: Already and certainly will break the recordPride Feng Qing
Differences between heap and Stack in JavaLittle hands, son.
Conversion of JSON strings to Java objectsArnold
type conversion of int, string in JavaMystery Piggy
more >>Recommended Posts
20
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.