Package com.upokecenter.cbor
Class JSONOptions
- java.lang.Object
-
- com.upokecenter.cbor.JSONOptions
-
public final class JSONOptions extends java.lang.Object
Includes options to control how CBOR objects are converted to JSON.
-
-
Field Summary
Fields Modifier and Type Field Description static JSONOptions
Default
The default options for converting CBOR objects to JSON.
-
Constructor Summary
Constructors Constructor Description JSONOptions()
Initializes a new instance of theJSONOptions
class with default options.JSONOptions(boolean base64Padding)
Initializes a new instance of theJSONOptions
class with the given value for the Base64Padding option.JSONOptions(boolean base64Padding, boolean replaceSurrogates)
Initializes a new instance of theJSONOptions
class with the given values for the options.JSONOptions(java.lang.String paramString)
Initializes a new instance of theJSONOptions
class.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
getBase64Padding()
Deprecated.This option now has no effect.boolean
getReplaceSurrogates()
Gets a value indicating whether surrogate code points not part of a surrogate pair (which consists of two consecutivechar
s forming one Unicode code point) are each replaced with a replacement character (U+FFFD).java.lang.String
toString()
Gets the values of this options object's properties in text form.
-
-
-
Field Detail
-
Default
public static final JSONOptions Default
The default options for converting CBOR objects to JSON.
-
-
Constructor Detail
-
JSONOptions
public JSONOptions()
Initializes a new instance of theJSONOptions
class with default options.
-
JSONOptions
public JSONOptions(boolean base64Padding)
Initializes a new instance of theJSONOptions
class with the given value for the Base64Padding option.- Parameters:
base64Padding
- Whether padding is included when writing data in base64url or traditional base64 format to JSON.
-
JSONOptions
public JSONOptions(boolean base64Padding, boolean replaceSurrogates)
Initializes a new instance of theJSONOptions
class with the given values for the options.- Parameters:
base64Padding
- Whether padding is included when writing data in base64url or traditional base64 format to JSON.replaceSurrogates
- Whether surrogate code points not part of a surrogate pair (which consists of two consecutivechar
s forming one Unicode code point) are each replaced with a replacement character (U+FFFD). The default is false; an exception is thrown when such code points are encountered.
-
JSONOptions
public JSONOptions(java.lang.String paramString)
Initializes a new instance of theJSONOptions
class.- Parameters:
paramString
- A string setting forth the options to use. This is a semicolon-separated list of options, each of which has a key and a value separated by an equal sign ("="). Whitespace and line separators are not allowed to appear between the semicolons or between the equal signs, nor may the string begin or end with whitespace. The string can be empty, but cannot be null. The following is an example of this parameter:base64padding = false;replacesurrogates = true
. The key can be any one of the following in any combination of case:base64padding
,replacesurrogates
. Other keys are ignored. (Keys are compared using a basic case-insensitive comparison, in which two strings are equal if they match after converting the basic upper-case letters A to Z (U+0041 to U+005A) in both strings to basic lower-case letters.) If two or more key/value pairs have equal keys (in a basic case-insensitive comparison), the value given for the last such key is used. The two keys just given can have a value of1
,true
,yes
, oron
(in any combination of case), which means true, and any other value meaning false. For example,base64padding = Yes
andbase64padding = 1
both set theBase64Padding
property to true.- Throws:
java.lang.NullPointerException
- The parameterparamString
is null.
-
-
Method Detail
-
toString
public java.lang.String toString()
Gets the values of this options object's properties in text form.- Overrides:
toString
in classjava.lang.Object
- Returns:
- A text string containing the values of this options object's properties. The format of the string is the same as the one described in the string constructor for this class.
-
getBase64Padding
@Deprecated public final boolean getBase64Padding()
Deprecated.This option now has no effect. This library now includes necessary padding when writing traditional base64 to JSON and includes no padding when writing base64url to JSON, in accordance with the revision of the CBOR specification.Gets a value indicating whether the Base64Padding property is true. This property has no effect; in previous versions, this property meant that padding was written out when writing base64url or traditional base64 to JSON.- Returns:
- A value indicating whether the Base64Padding property is true.
-
getReplaceSurrogates
public final boolean getReplaceSurrogates()
Gets a value indicating whether surrogate code points not part of a surrogate pair (which consists of two consecutivechar
s forming one Unicode code point) are each replaced with a replacement character (U+FFFD). The default is false; an exception is thrown when such code points are encountered.- Returns:
- True, if surrogate code points not part of a surrogate pair are each replaced with a replacement character, or false if an exception is thrown when such code points are encountered.
-
-