public final class JsonStringEncoder extends 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.
Modifier and Type | Field and Description |
---|---|
protected ByteArrayBuilder |
_bytes
Lazily-constructed builder used for UTF-8 encoding of text values
(quoted and unquoted)
|
protected char[] |
_qbuf
Temporary buffer used for composing quote/escape sequences
|
protected TextBuffer |
_text
Lazily constructed text buffer used to produce JSON encoded Strings
as characters (without UTF-8 encoding)
|
Constructor and Description |
---|
JsonStringEncoder() |
Modifier and Type | Method and Description |
---|---|
byte[] |
encodeAsUTF8(String text)
Will encode given String as UTF-8 (without any quoting), return
resulting byte array.
|
static JsonStringEncoder |
getInstance()
Deprecated.
Since 2.9.2 use
BufferRecyclers.getJsonStringEncoder() instead |
void |
quoteAsString(CharSequence input,
StringBuilder output)
Method that will quote text contents using JSON standard quoting,
and append results to a supplied
StringBuilder . |
char[] |
quoteAsString(String input)
Method that will quote text contents using JSON standard quoting,
and return results as a character array
|
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.
|
protected TextBuffer _text
protected ByteArrayBuilder _bytes
protected final char[] _qbuf
@Deprecated public static JsonStringEncoder getInstance()
BufferRecyclers.getJsonStringEncoder()
insteadpublic char[] quoteAsString(String input)
public void quoteAsString(CharSequence input, StringBuilder output)
StringBuilder
.
Use this variant if you have e.g. a StringBuilder
and want to avoid superfluous copying of it.public byte[] quoteAsUTF8(String text)
public byte[] encodeAsUTF8(String text)
Copyright © 2008–2017 FasterXML. All rights reserved.