Class JsonEscaper


  • public class JsonEscaper
    extends Object
    Json string escaper for string literals.
    Author:
    antons
    • Constructor Detail

      • JsonEscaper

        public JsonEscaper()
    • Method Detail

      • escapeChar

        public static String escapeChar​(int c)
        Escapes character
        Parameters:
        c - input character
        Returns:
        escaped sequence for provided input
      • unescapeChar

        public static char unescapeChar​(String value)
        Unescape escaped string into character.
        Parameters:
        value - escapes sequence
        Returns:
        char defined by input.
      • unescapeChar

        public static char unescapeChar​(String value,
                                        int pos)
        Unescape escaped string into character.
        Parameters:
        value - string
        pos - position of escape sequence in string
        Returns:
        char defined by input.
      • escape

        public static String escape​(String value)
        Escape input string.
        Parameters:
        value - input string
        Returns:
        escaped string.
      • escape

        public static String escape​(String value,
                                    boolean escapeNonAscii)
        Escape input string.
        Parameters:
        value - input string
        escapeNonAscii - escape non asci charasters
        Returns:
        escaped string
      • escape

        public static String escape​(String value,
                                    boolean escapeNonAscii,
                                    int offset,
                                    int length)
        Escape input string.
        Parameters:
        value - input string
        escapeNonAscii - escape non asci charasters
        offset - start position of string to be escaped
        length - length of string to be escaped
        Returns:
        escaped string
      • unescape

        public static String unescape​(String value)
        Unescape string
        Parameters:
        value - escaped string
        Returns:
        unescaped string
      • unescape

        public static String unescape​(String value,
                                      int offset,
                                      int length)
        Unescape string
        Parameters:
        value - escaped string
        offset - start position of string to be unescaped
        length - length of string to be unescaped
        Returns:
        unescaped string
      • main

        public static void main​(String[] params)