public class Quote extends Object
See rfc4627 on quoted string:
string = quotation-mark *char quotation-mark char = unescaped / escape ( %x22 / ; " quotation mark U+0022 %x5C / ; \ reverse solidus U+005C %x2F / ; / solidus U+002F %x62 / ; b backspace U+0008 %x66 / ; f form feed U+000C %x6E / ; n line feed U+000A %x72 / ; r carriage return U+000D %x74 / ; t tab U+0009 %x75 4HEXDIG ) ; uXXXX U+XXXX escape = %x5C ; \ quotation-mark = %x22 ; " unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
Constructor and Description |
---|
Quote() |
Modifier and Type | Method and Description |
---|---|
static String |
quote(String str)
This function double quotes a string and escapes characters as
necessary so that the generated string can be used either as
the key name or raw string value.
|
static void |
quote(Writer out,
String str)
Quote a string
|
public static void quote(Writer out, String str) throws IOException
out
- writerstr
- string to be quoted and writtenIOException
- in case of I/O error.public static String quote(String str)
The main use case of this function is to generate double quoted
key names. This way, by setting TextJsonGenerator.setKeyNameEscaped(boolean)
to true, user can improve the JSON output performance in applications
where the same key names are being used over and over again (such
as database ResultSet).
str
- the string to be double quoted.Copyright © 2016. All rights reserved.