本文整理了Java中org.apache.commons.text.StringEscapeUtils.unescapeJson()
方法的一些代码示例,展示了StringEscapeUtils.unescapeJson()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringEscapeUtils.unescapeJson()
方法的具体详情如下:
包路径:org.apache.commons.text.StringEscapeUtils
类名称:StringEscapeUtils
方法名:unescapeJson
暂无
代码示例来源:origin: org.apache.commons/commons-text
@Test
public void testUnescapeJson() {
final String jsonString =
"{\"age\":100,\"name\":\"kyong.com\n\",\"messages\":[\"msg 1\",\"msg 2\",\"msg 3\"]}";
assertEquals("", StringEscapeUtils.unescapeJson(""));
assertEquals(" ", StringEscapeUtils.unescapeJson(" "));
assertEquals("a:b", StringEscapeUtils.unescapeJson("a:b"));
assertEquals(jsonString, StringEscapeUtils.unescapeJson(jsonString));
}
代码示例来源:origin: org.apache.commons/commons-text
@Test // TEXT-120
public void testUnescapeJsonDoubleQuoteAndForwardSlash() {
final String escapedJsonString = "double quote: \\\" and a forward slash: \\/";
final String jsonString = "double quote: \" and a forward slash: /";
assertEquals(jsonString, StringEscapeUtils.unescapeJson(escapedJsonString));
}
代码示例来源:origin: seanchenxi/gwt-storage
private void appendStringTable(String[] stringTable){
append(String.valueOf(stringTable.length));
for (String st : stringTable) {
String value = unescapeJson(st).replace(PIPE, RPC_PIPE_REPLACE);
append(value);
}
}
代码示例来源:origin: org.onap.ccsdk.sli.core/sliPluginUtils-provider
/**
* jsonStringToCtx takes a json string stored as a single property in context memory and breaks it into individual properties
* @param parameters - requires source, outputPath and isEscaped to not be null.
* @param ctx Reference to context memory
* @throws SvcLogicException if a required parameter is missing an exception is thrown
*/
public static void jsonStringToCtx(Map<String, String> parameters, SvcLogicContext ctx) throws SvcLogicException
{
checkParameters(parameters, new String[] { "source","outputPath","isEscaped" }, LOG);
try {
String source = ctx.getAttribute(parameters.get("source"));
if("true".equals(parameters.get("isEscaped"))){
source = StringEscapeUtils.unescapeJson(source);
}
writeJsonToCtx(source, ctx,parameters.get("outputPath"));
} catch (Exception ex) {
throw new SvcLogicException("problem with jsonStringToCtx", ex);
}
}
内容来源于网络,如有侵权,请联系作者删除!