One 、 Test data preparation
List<Map<String, String>> result = new ArrayList();
Map<String, String> map = new HashMap<>();
map.put("san", " Zhang San ");
map.put("si", " Li Si ");
map.put("wu", " Wang Wu ");
map.put("wang", " Lao Wang ");
map.put("lao", " Lao zhang ");
result.add(map);
Two 、 take list<Map<String, String>> The structural data of is converted into json Array
JSONArray jsonArray = JSONArray.parseArray(JSONArray.toJSON(result).toString());
System.out.println(jsonArray);
give the result as follows :
-------------------------------------------------------------------------------------------------
--------------[{"san":" Zhang San ","wang":" Lao Wang ","si":" Li Si ","lao":" Lao zhang ","wu":" Wang Wu "}]-------------------
-------------------------------------------------------------------------------------------------
3、 ... and 、 obtain json The array corresponds to key Value
// 1. First, traverse the data
for (Object o : jsonArray) {
// 2. Then object Turn into JsonObject type
JSONObject jsonObject = (JSONObject) JSONObject.parse(JSON.toJSONString(o));
// 3. Finally, according to the corresponding key Get the corresponding value value
System.out.println(jsonObject.get("san"));
System.out.println(jsonObject.get("wang"));
System.out.println(jsonObject.get("si"));
System.out.println(jsonObject.get("lao"));
System.out.println(jsonObject.get("wu"));
} give the result as follows :
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
------------------------------ Zhang San Lao Wang Li Si Lao zhang Wang Wu -----------------------------------------
---------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------
Four 、 call Entry Object getkey() and getValue() Method to get the key value
According to... In the data key obtain value More articles on value
- JavaScript Use... In functions Ajax Get the value as the return value of the function
solve :JavaScript Use... In functions Ajax Get the value as the return value of the function , The result cannot get the return value reason :ajax Asynchronous mode is used by default , To change asynchronous mode to synchronous mode Case study : Through the region ID, Get all the schools in the area var ...
- [Jacky] solve Ext.Net GridPanel The latest value cannot be obtained after the selected row data is refreshed
choice GridPanel A row of data in , When the data is changed and refreshed, the latest value cannot be obtained , It needs to be obtained through the following ways : var internalId = gridPanel.getSelectionModel().getL ...
- my Android An advanced journey ------> solve Jackson、Gson analysis Json Data time ,Json In the data Key by Java The key word is null The problem of
1. Problem description First , It needs to be parsed Json The data is similar to the following format , But it includes Java keyword abstract: { ret: 0, msg: "normal return.", news: ...
- shopnc export Excel Examples of data problems && ajax Get the current value and pass
Mission : Export data from the Merchant Center , The situation of each commodity . Export goods to Excel File function / export exel function make-in-lemon public function createExcelOp(){ $mode ...
- JavaScript In order to get Map In the collection key and value value ( Premise is : Neither know key Why is it worth , I don't know. value What are the values )
for(var i in maps){// By defining a local variable i Traversal access map Everything in it key value alert(maps[i]); // By acquiring key Corresponding value value }
- mysql In multiple data , Group the data record with the largest value
Abstract : In multiple records , Several fields are the same , But one or more of these fields are different , Then the maximum value of this field is ( There is only one difference ) Source data : The purpose is to remove : Only one day of data can exist in the same day , The maximum approval date is taken , The database script is as follows : SELECT ...
- stay JavaScript In order to get Map In the collection key and value value ( Premise is : Neither know key Why is it worth , I don't know. value What are the values )
- stay java In order to get Map In the collection key and value value
- java According to the key obtain resource Next properties The corresponding parameters in the resource file
properties The resource file is placed in resource In the catalog : New tool class : package com.demo.utils; import java.io.InputStream; import jav ...
- MYSQL - JSON Find... In the string key Corresponding value
1. Build table -- Build table drop table if exists ta_product2; CREATE TABLE ta_product2( id int primary key auto_incre ...
Random recommendation
- C# Convert absolute path to relative path
introduction In the project, it is often necessary to set the absolute path , Convert to relative path , To increase the flexibility of program related configuration ( There is no need for our program to not work properly just because the whole system is moved ) The solution Write your own code to solve : private strin ...
- IIS Summary of relevant experience in deploying the site
IIS Summary of relevant experience in deploying the site 1.IIS and .net4.0 The installation is sequential , You should install .net framework 4.0, Install again IIS. If installed in reverse order ,IIS I can't see 4.0 Relevant stuff , Then only ...
- Have a good command of js in this Usage of , analysis this Role in different application scenarios
Because of its runtime binding nature ,JavaScript Medium this The meaning is much richer , It can be a global object . The current object or any object , It all depends on how the function is called . JavaScript There are several ways to call functions in : do ...
- Ten classics office Practical skills
IT Engineers have to work in the workplace office Software ( Not Jinshan WPS), among ppt The most important and difficult thing to learn . I have already shared with you , This article is about word And excel Ten hidden skills . One .Excel Table calculation formula 1. Sum all values :SUM ...
- [ Driver registration ]platform_driver_register() And platform_device_register()
[ Driver registration ]platform_driver_register() And platform_device_register() Two binding methods of device and driver : Binding during device registration and driver registration . ...
- Use java Realized socket agent ( Support socket4 and socket5)
The code is as follows : import java.io.*; import java.net.InetAddress; import java.net.ServerSocket; import java.net.S ...
- listview Load asynchronously
http://www.iteye.com/topic/685986 ListView Loading images asynchronously is a very practical method , Generally, it is better to use this method to obtain picture resources through the network , Good user experience , Let's talk about the implementation method , Post first ...
- vector Wonderful use of easy water over the balance tree ???
Very short code warning Today, I heard from the gods around me , It can be used vector To write a balanced tree , The code is very short . Then I searched the Internet , I saw it attack dalao This article of . Konjaku ssfd I quickly worshipped a wave , And published a blog to commemorate . ...
- HTTP Request a complete list of common errors
common Http Request error message 1xx - The message indicates that these status codes represent a temporary response . Before the client receives a regular response , Should be ready to receive one or more 1xx Respond to .100 - continue 101 - Handover protocol 2xx - The state of success ...
- linux in jdk Installation and mysql Installation
1.linux install jdk # First find Installation package #cd /usr/java tar -zxvf jdk-8u31-linux-x64.tar.gz 2. Install select to install java The location of , Such as /usr/ Under the table of contents , newly build ...
![class path resource [classpath*:mapper/*.xml] cannot be opened because it does not exist](/img/1a/294eb0128285686ede415991f69be7.png)








