Class StringEscapeUtils


  • public final class StringEscapeUtils
    extends java.lang.Object
    Utilities for JSON escaping String.

    Implementation Approach

    This uses a replacement char array to perform escaping, an idea from Square/Moshi. In their case, it was an internal detail of com.squareup.moshi.JsonUtf8Writer, licensed Apache 2.0 Copyright 2010 Google Inc. The comments and initialization of REPLACEMENT_CHARS came directly from Moshi's JsonUtf8Writer.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String escapeJson​(java.lang.String v)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • escapeJson

        public static java.lang.String escapeJson​(@Nullable
                                                  java.lang.String v)