Home >Web Front-end >JS Tutorial >jQuery jqgrid's Java processing method for json data containing special characters_jquery

jQuery jqgrid's Java processing method for json data containing special characters_jquery

WBOY
WBOYOriginal
2016-05-16 18:12:491087browse

I saw that a lot of online processing of json data containing special characters involves determining which special characters they are one by one, such as how to handle carriage returns and how to handle quotation marks. In fact, there is a ready-made code library that can do this, download json-lib-2.3-jdk15.jar:

Copy the code Code As follows:

import net.sf.json.util.JSONUtils;

String str = (String) value;
String s1 = JSONUtils.quote(str);/ /With first and last quotation marks
String s3 = JSONUtils.stripQuotes(s1);//Remove the first quotation mark
return s3;

This code is very concise.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn