Map<string,string> Converting JSON strings

Source: Internet
Author: User

First Note: Note the Import and introduction of JAR packages.

Here is the code implementation:

1 ImportJava.util.HashMap;2 ImportJava.util.Map;3 ImportNet.sf.json.JSONObject;4 5  Public classTestjson {6  7      Public Static voidMain (string[] args) {8 testpingping ();9     }Ten     //the tasks are all my friends, I hope they don't see ^_^ ^_^ ^_^ One      Public Static voidtestpingping () { Amap<string, string> smallmap =NewHashmap<string, string>();  -Smallmap.put ("UserId", "438"); -Smallmap.put ("name", "Flat/ping"); theSmallmap.put ("Sex", "I don't know men and women"); -Smallmap.put ("Reason", "and studies to sleep one night, later studies mouth ache");  -Jsonobject Jsonobject =Jsonobject.fromobject (smallmap); -System.out.println ("The following are experts ' findings:"); + System.out.println (jsonobject); -SYSTEM.OUT.PRINTLN ("Patient identification completed!") "); +System.out.println ("Next"); A  at     }  -}

Results of the output:

The following are experts ' findings:
{"B_name": "Flat/Ping Ping", "D_reason": "and studies to sleep one night, later studies mouth pain", "A_userid": "438", "c_sex": "I do not know men and women"}
Patient Identification Complete!
Next one

--------------------------------------------------------------------------------------------------

List of jar packages to be introduced:

Cglib-nodep-2.2.jar
Commons-beanutils-1.8.0.jar
Commons-collections-3.2.1.jar
Commons-lang-2.4.jar
Commons-logging-1.1.1.jar
Ezmorph-1.0.4.jar
Gson-2.8.0-javadoc.jar
Gson-2.8.0-sources.jar
Gson-2.8.0.jar
Jettison-1.3.1.jar
Json-lib-2.2.1-jdk13.jar
Json.jar

--------------------------------------------------------------------------------------------------

Ping elder brother ^_^ ha haha haha .....

Map<string,string> Converting JSON strings

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: info-contact@alibabacloud.com 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.