On Wed, Apr 10, 2013 at 8:41 PM, Maurizio Cucchiara <[email protected]> wrote: > There are a lot of reasons which let me think that having inside the > StringEscapeUtils class is a legitimate idea: > 1. take a look at SEU's methods [2] > 2. adding a new dependency, just for json escaping, seems excessive to me. > 3. Last but not least there is already an open issue [1], and FYI I > have already submitted a patch.
I am using StringEscapeUtils for that task in my JSON lib: https://github.com/grobmeier/jjson/blob/master/jjson/src/main/java/de/grobmeier/jjson/convert/JSONAnnotationEncoder.java (line 274) private void encodeString(String string, StringBuilder result, JSON annotation) { if(string == null) { result.append(NULL); } else { result.append(QUOTE); result.append(StringEscapeUtils.escapeJava(string)); result.append(QUOTE); } } It works pretty well for me. Note, I am using it actually with Struts 2, I created a simple JSON plugin in the same repos. If its of use, I am willing to contribute everything to whereever it makes sense Cheers Christian > > [1] https://issues.apache.org/jira/browse/LANG-797 > [2] > http://commons.apache.org/proper/commons-lang//apidocs/org/apache/commons/lang3/StringEscapeUtils.html#method_summary > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > -- http://www.grobmeier.de https://www.timeandbill.de --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
