List of usage examples for com.google.gwt.core.client JsonUtils escapeValue
public static native String escapeValue(String toEscape) ;
From source file:com.github.nmorel.gwtjackson.client.stream.impl.FastJsonWriter.java
License:Apache License
private void string(String value) { out.append(JsonUtils.escapeValue(value)); }
From source file:com.google.walkaround.util.client.log.ErrorReportingLogHandler.java
License:Open Source License
String escape(String unescaped) { // + "" to avoid null return JsonUtils.escapeValue(unescaped != null ? unescaped : "(null)"); }
From source file:com.google.web.bindery.autobean.gwt.client.impl.JsoSplittable.java
License:Apache License
public String getPayload() { if (isString()) { return JsonUtils.escapeValue(asString()); }//w ww.j a va 2s . com if (stringifyFastSupported()) { return stringifyFast(); } return stringifySlow(); }
From source file:com.google.web.bindery.autobean.gwt.client.impl.JsoSplittable.java
License:Apache License
private void stringifySlow(StringBuilder sb) { if (this == NULL) { sb.append("null"); return;/*from w w w . j ava 2 s . co m*/ } if (isBoolean()) { sb.append(asBoolean()); return; } if (isNumber()) { sb.append(asNumber()); return; } if (isString()) { sb.append(JsonUtils.escapeValue(asString())); return; } if (isIndexed()) { sb.append("["); for (int i = 0, j = size(); i < j; i++) { if (i > 0) { sb.append(","); } get(i).stringifySlow(sb); } sb.append("]"); return; } sb.append("{"); boolean needsComma = false; for (String key : getPropertyKeys()) { if (needsComma) { sb.append(","); } else { needsComma = true; } JsoSplittable value = get(key); if (!value.isFunction()) { if ("$H".equals(key)) { // Ignore hashcode continue; } sb.append(JsonUtils.escapeValue(key)); sb.append(":"); value.stringifySlow(sb); } } sb.append("}"); }
From source file:com.google.web.bindery.autobean.shared.impl.StringQuoter.java
License:Apache License
public static String quote(String raw) { return JsonUtils.escapeValue(raw); }
From source file:com.gwtmodel.table.json.CreateJson.java
License:Apache License
String createJsonString() { String res = "{ \"" + objectName + "\": {"; boolean first = true; for (Entry<String, JsonElem> e : vals.entrySet()) { if (!first) { res += " , "; }/*from w ww. ja v a2 s .c om*/ first = false; String val; if (e.getValue().getVal() == null) { val = IConsts.JSNULL; } else { if (e.getValue().isNumber()) { val = e.getValue().getVal(); if (CUtil.EmptyS(val)) { val = IConsts.JSNULL; } } else { String s = e.getValue().getVal(); // escape all " // TODO: remove now s = s.replaceAll("\"", ""); s = s.replaceAll("'", ""); // escape all \n s = s.replaceAll("\n", ""); s = s.replaceAll("\r", ""); val = JsonUtils.escapeValue(s); } } res += '\"' + e.getKey() + "\" : " + val; } res += "}}"; return res; }
From source file:com.kk_electronic.kkportal.core.rpc.jsonformat.JsonString.java
License:Open Source License
@Override public void toJson(StringBuilder response, String object, FrameEncoder<JSONValue> encoder) throws UnableToSerialize { response.append(JsonUtils.escapeValue(object)); }
From source file:com.kk_electronic.kkportal.core.util.JsonValueHelper.java
License:Open Source License
public static void toJson(String s, StringBuilder sb, String arraysep, String kvsep) { sb.append(JsonUtils.escapeValue(s)); }
From source file:com.kk_electronic.kkportal.core.util.JsonValueHelper.java
License:Open Source License
public static void toJson(Map<?, ?> m, StringBuilder sb, String arraysep, String kvsep) { Set<?> k = m.keySet();/*w w w .ja v a 2 s . co m*/ for (Iterator<?> iterator = k.iterator(); iterator.hasNext();) { Object e = iterator.next(); sb.append(JsonUtils.escapeValue((String) e)); sb.append(kvsep); toJson(m.get(e), sb, arraysep, kvsep); } }
From source file:com.seanchenxi.gwt.storage.client.serializer.StorageSerializationStreamWriter.java
License:Apache License
private String escapeString(String toEscape) { if (toEscape == null) return null; return JsonUtils.escapeValue(toEscape); }