PeterO.Cbor.JSONOptions

## PeterO.Cbor.JSONOptions

public sealed class JSONOptions

Includes options to control how CBOR objects are converted to and from JavaScript Object Notation (JSON).

Member Summary

### JSONOptions Constructor

public JSONOptions(
    bool base64Padding);

Deprecated. Use the more readable string constructor instead.

Initializes a new instance of the PeterO.Cbor.JSONOptions class with the given value for the Base64Padding option.

Parameters:

### JSONOptions Constructor

public JSONOptions(
    bool base64Padding,
    bool replaceSurrogates);

Deprecated. Use the more readable string constructor instead.

Initializes a new instance of the PeterO.Cbor.JSONOptions class with the given values for the options.

Parameters:

### JSONOptions Constructor

public JSONOptions(
    string paramString);

Initializes a new instance of the PeterO.Cbor.JSONOptions class.

Parameters:

Exceptions:

### JSONOptions Constructor

public JSONOptions();

Initializes a new instance of the PeterO.Cbor.JSONOptions class with default options.

### Default

public static readonly PeterO.Cbor.JSONOptions Default;

The default options for converting CBOR objects to JSON.

### AllowDuplicateKeys

public bool AllowDuplicateKeys { get; }

Gets a value indicating whether to allow duplicate keys when reading JSON. Used only when decoding JSON. If this property is true and a JSON object has two or more values with the same key, the last value of that key set forth in the JSON object is taken.

Returns:

A value indicating whether to allow duplicate keys when reading JSON. The default is false.

### Base64Padding

public bool Base64Padding { get; }

Deprecated. This property 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.

### KeepKeyOrder

public bool KeepKeyOrder { get; }

Gets a value indicating whether to preserve the order in which a map’s keys appear when decoding JSON, by using maps created as though by CBORObject.NewOrderedMap. If false, key order is not guaranteed to be preserved when decoding JSON.

Returns:

A value indicating whether to preserve the order in which a CBOR map’s keys appear when decoding JSON. The default is false.

### NumberConversion

public PeterO.Cbor.JSONOptions.ConversionMode NumberConversion { get; }

Gets a value indicating how JSON numbers are decoded to CBOR objects. None of the conversion modes affects how CBOR objects are later encoded (such as via EncodeToBytes ).

Returns:

A value indicating how JSON numbers are decoded to CBOR. The default is ConversionMode.Full .

### PreserveNegativeZero

public bool PreserveNegativeZero { get; }

Gets a value indicating whether the JSON decoder should preserve the distinction between positive zero and negative zero when the decoder decodes JSON to a floating-point number format that makes this distinction. For a value of false , if the result of parsing a JSON string would be a floating-point negative zero, that result is a positive zero instead. (Note that this property has no effect for conversion kind IntOrFloatFromDouble , where floating-point zeros are not possible.).

Returns:

A value indicating whether to preserve the distinction between positive zero and negative zero when decoding JSON. The default is true.

### ReplaceSurrogates

public bool ReplaceSurrogates { get; }

Gets a value indicating whether surrogate code points not part of a surrogate pair (which consists of two consecutive char s forming one Unicode code point) are each replaced with a replacement character (U+FFFD). If 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. The default is false.

### WriteBasic

public bool WriteBasic { get; }

Gets a value indicating whether JSON is written using only code points from the Basic Latin block (U+0000 to U+007F), also known as ASCII.

Returns:

A value indicating whether JSON is written using only code points from the Basic Latin block (U+0000 to U+007F), also known as ASCII. Default is false.

### ToString

public override string ToString();

Gets the values of this options object’s properties in text form.

Return Value:

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.

Back to CBOR start page.