Android Open Source - RealtimeMessaging-Android Char Escaper

From Project

Back to project page RealtimeMessaging-Android.


The source code is released under:

MIT License

If you think the Android project RealtimeMessaging-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package ibt.ortc.extensibility;
//from  w  w  w  . j  a v a  2s . c  o  m
import org.json.simple.JSONValue;

public class CharEscaper {
  public static String removeEsc(String str){
    Object o1 = JSONValue.parse("\""+str+"\"");
    Object o2 = JSONValue.parse("\""+o1.toString()+"\"");
    return o2.toString();        
  public static String addEsc(String str){
    String pass1 = JSONValue.toJSONString(str);
    pass1 = pass1.substring(1, pass1.length()-1);
    String pass2 = JSONValue.toJSONString(pass1);
    pass2 = pass2.substring(1, pass2.length()-1);
    return pass2;

Java Source Code List