A quick way to convert a map to JSON format in Java _java

Source: Internet
Author: User

In daily use, we usually encounter map to JSON, if the traversal will waste a lot of time, in fact, we have such a jar package

Copy Code code as follows:

The method * * * is undefined which package is missing for the type jsonobject------
Json-lib.jar

It's still not going to work. Need a dependent jar package or you'll get an error.

Copy Code code as follows:

Java.lang.ClassNotFoundException:net.sf.ezmorph.Morpher

When when the jar package is Ezmorph-***.jar

The following methods we use are

Jsonserializer.tojson (Map Object)

For example, our map object is

Copy Code code as follows:

{TIME=2015/04/10, carnum= A2212, mark= front bumper damaged, headlights damaged, billnum=100232113213r}

The result of converting to JSON is
Copy Code code as follows:

{"Time": "2015/04/10", "Carnum": "Jing A2212", "Mark": "Front bumper damaged, headlamps damaged", "Billnum": "100232113213R"}

Is it a super love

Related Article

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.