Class StringEscapeUtils

java.lang.Object
io.micrometer.core.instrument.util.StringEscapeUtils

public final class StringEscapeUtils extends 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 Details

    • escapeJson

      public static String escapeJson(@Nullable String v)