public final class JsonStringEncoder
extends java.lang.Object
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 and Description |
---|
JsonStringEncoder() |
Modifier and Type | Method and Description |
---|---|
byte[] |
encodeAsUTF8(java.lang.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(java.lang.CharSequence input)
Overloaded variant of
quoteAsString(String) . |
void |
quoteAsString(java.lang.CharSequence input,
java.lang.StringBuilder output)
Method that will quote text contents using JSON standard quoting,
and append results to a supplied
StringBuilder . |
char[] |
quoteAsString(java.lang.String input)
Method that will quote text contents using JSON standard quoting,
and return results as a character array
|
byte[] |
quoteAsUTF8(java.lang.String text)
Will quote given JSON String value using standard quoting, encode
results as UTF-8, and return result as a byte array.
|
public static JsonStringEncoder getInstance()
public char[] quoteAsString(java.lang.String input)
public char[] quoteAsString(java.lang.CharSequence input)
quoteAsString(String)
.public void quoteAsString(java.lang.CharSequence input, java.lang.StringBuilder output)
StringBuilder
.
Use this variant if you have e.g. a StringBuilder
and want to avoid superfluous copying of it.public byte[] quoteAsUTF8(java.lang.String text)
public byte[] encodeAsUTF8(java.lang.String text)
Copyright © 2010 - 2020 Adobe. All Rights Reserved