Java processing method of jQuery jqgrid for json data containing special characters

Source: Internet
Author: User
Tags jqgrid

We can see that many websites process json data containing special characters on the Internet, and determine the special characters one by one, such as how to handle carriage return and how to process quotation marks. In fact there is a ready-made code library can do this thing, download json-lib-2.3-jdk15.jar:
Copy codeThe Code is as follows:
Import net. sf. json. util. JSONUtils;

String str = (String) value;
String s1 = JSONUtils. quote (str); // start and end with quotation marks
String s3 = JSONUtils. stripQuotes (s1); // remove the first quotation mark
Return s3;

This code is concise.

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.