List of usage examples for org.apache.commons.lang3 StringEscapeUtils escapeEcmaScript
public static final String escapeEcmaScript(final String input)
Escapes the characters in a String using EcmaScript String rules.
Escapes any values it finds into their EcmaScript String form.
From source file:randori.compiler.internal.codegen.js.RandoriEmitter.java
@Override public void emitLiteral(ILiteralNode node) { String value = node.getValue(false); if (node.getLiteralType() == LiteralType.STRING) { value = "\"" + StringEscapeUtils.escapeEcmaScript(value) + "\""; }//from w w w. jav a 2s .c o m write(value); }
From source file:ro.uaic.info.nlptools.ggs.engine.core.StateMachine.java
public static String tokenToJson(Token token) { StringBuilder sb = new StringBuilder("{\n"); sb.append("index : ").append(token.getTokenIndexInSentence()).append(",\n"); sb.append("parentAnnotations : [],\n"); {/*from ww w . j ava2 s . c om*/ sb.append("features:{"); for (Map.Entry<String, String> entry : token.getFeatures().entrySet()) { sb.append("'").append(StringEscapeUtils.escapeEcmaScript(entry.getKey())).append("' : \"") .append(StringEscapeUtils.escapeEcmaScript(entry.getValue())).append("\",\n"); } sb.delete(sb.length() - 2, sb.length()); sb.append("}"); } sb.append("}"); return sb.toString(); }
From source file:ro.uaic.info.nlptools.ggs.engine.core.StateMachine.java
public static String annotationToJson(SpanAnnotation annotation) { StringBuilder sb = new StringBuilder("{\n"); sb.append("name : '").append(annotation.getName()).append("',\n"); sb.append("startToken : sentence[").append(annotation.getStartTokenIndex()).append("],\n"); sb.append("endToken : sentence[").append(annotation.getEndTokenIndex()).append("]\n"); if (annotation.getFeatures().size() > 0) { sb.append(",features:{"); for (Map.Entry<String, String> entry : annotation.getFeatures().entrySet()) { sb.append("\"").append(StringEscapeUtils.escapeEcmaScript(entry.getKey())).append("\" : \"") .append(StringEscapeUtils.escapeEcmaScript(entry.getValue())).append("\",\n"); }/*ww w . j a v a 2s. c o m*/ sb.delete(sb.length() - 2, sb.length()); sb.append("}"); } sb.append("}"); return sb.toString(); }
From source file:us.mn.state.health.lims.dashboard.action.DashboardAction.java
private String asJson(Object o) throws IOException { String listJson = ObjectMapperRepository.objectMapper.writeValueAsString(o); return StringEscapeUtils.escapeEcmaScript(listJson); }