Package com.fasterxml.jackson.core.io
Class JsonStringEncoder
- java.lang.Object
-
- com.fasterxml.jackson.core.io.JsonStringEncoder
-
public final class JsonStringEncoder extends Object
Helper class used for efficient encoding of JSON String values (including JSON field names) into Strings or UTF-8 byte arrays.Note that methods in here are somewhat optimized, but not ridiculously so. Reason is that conversion method results are expected to be cached so that these methods will not be hot spots during normal operation.
-
-
Constructor Summary
Constructors Constructor Description JsonStringEncoder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
encodeAsUTF8(CharSequence text)
Overloaded variant ofencodeAsUTF8(String)
.byte[]
encodeAsUTF8(String text)
Will encode given String as UTF-8 (without any quoting), return resulting byte array.static JsonStringEncoder
getInstance()
Factory method for getting an instance; this is either recycled per-thread instance, or a newly constructed one.char[]
quoteAsString(CharSequence input)
Overloaded variant ofquoteAsString(String)
.void
quoteAsString(CharSequence input, StringBuilder output)
Method that will quote text contents using JSON standard quoting, and append results to a suppliedStringBuilder
.char[]
quoteAsString(String input)
Method that will quote text contents using JSON standard quoting, and return results as a character arraybyte[]
quoteAsUTF8(String text)
Will quote given JSON String value using standard quoting, encode results as UTF-8, and return result as a byte array.
-
-
-
Method Detail
-
getInstance
public static JsonStringEncoder getInstance()
Factory method for getting an instance; this is either recycled per-thread instance, or a newly constructed one.
-
quoteAsString
public char[] quoteAsString(String input)
Method that will quote text contents using JSON standard quoting, and return results as a character array
-
quoteAsString
public char[] quoteAsString(CharSequence input)
Overloaded variant ofquoteAsString(String)
.- Since:
- 2.10
-
quoteAsString
public void quoteAsString(CharSequence input, StringBuilder output)
Method that will quote text contents using JSON standard quoting, and append results to a suppliedStringBuilder
. Use this variant if you have e.g. aStringBuilder
and want to avoid superfluous copying of it.- Since:
- 2.8
-
quoteAsUTF8
public byte[] quoteAsUTF8(String text)
Will quote given JSON String value using standard quoting, encode results as UTF-8, and return result as a byte array.
-
encodeAsUTF8
public byte[] encodeAsUTF8(String text)
Will encode given String as UTF-8 (without any quoting), return resulting byte array.
-
encodeAsUTF8
public byte[] encodeAsUTF8(CharSequence text)
Overloaded variant ofencodeAsUTF8(String)
.- Since:
- 2.11
-
-