PeterO.Cbor.CBORDataUtilities

## PeterO.Cbor.CBORDataUtilities

public static class CBORDataUtilities

Contains methods useful for reading and writing data, with a focus on CBOR.

Member Summary

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    byte[] bytes);

Parses a number from a byte sequence whose format follows the JSON specification. The method uses a JSONOptions with all default properties except for a PreserveNegativeZero property of false.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns positive zero if the number is a zero that starts with a minus sign (such as “-0” or “-0.0”). Returns null if the parsing fails, including if the byte sequence is null or empty.

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    byte[] bytes,
    int offset,
    int count);

Parses a number whose format follows the JSON specification (RFC 8259) from a portion of a byte sequence, and converts that number to a CBOR object.

Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (“.”, full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A byte sequence representing a valid JSON number is not allowed to contain white space characters, including spaces.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the byte sequence is null or empty.

Exceptions:

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    byte[] bytes,
    int offset,
    int count,
    PeterO.Cbor.JSONOptions options);

Parses a number from a byte sequence whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.

Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (“.”, full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A byte sequence representing a valid JSON number is not allowed to contain white space characters, including spaces.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the byte sequence is null or empty or count is 0 or less.

Exceptions:

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    byte[] bytes,
    PeterO.Cbor.JSONOptions options);

Parses a number from a byte sequence whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.

Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (“.”, full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A byte sequence representing a valid JSON number is not allowed to contain white space characters, including spaces.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the byte sequence is null or empty.

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    char[] chars);

Parses a number from a sequence of char s whose format follows the JSON specification. The method uses a JSONOptions with all default properties except for a PreserveNegativeZero property of false.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns positive zero if the number is a zero that starts with a minus sign (such as “-0” or “-0.0”). Returns null if the parsing fails, including if the sequence of char s is null or empty.

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    char[] chars,
    int offset,
    int count);

Parses a number whose format follows the JSON specification (RFC 8259) from a portion of a sequence of char s, and converts that number to a CBOR object.

Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (“.”, full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A sequence of char s representing a valid JSON number is not allowed to contain white space characters, including spaces.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the sequence of char s is null or empty.

Exceptions:

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    char[] chars,
    int offset,
    int count,
    PeterO.Cbor.JSONOptions options);

Parses a number from a sequence of char s whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.

Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (“.”, full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A sequence of char s representing a valid JSON number is not allowed to contain white space characters, including spaces.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the sequence of char s is null or empty or count is 0 or less.

Exceptions:

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    char[] chars,
    PeterO.Cbor.JSONOptions options);

Parses a number from a sequence of char s whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.

Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (“.”, full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A sequence of char s representing a valid JSON number is not allowed to contain white space characters, including spaces.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the sequence of char s is null or empty.

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    string str);

Parses a number whose format follows the JSON specification. The method uses a JSONOptions with all default properties except for a PreserveNegativeZero property of false.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns positive zero if the number is a zero that starts with a minus sign (such as “-0” or “-0.0”). Returns null if the parsing fails, including if the string is null or empty.

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    string str,
    bool integersOnly,
    bool positiveOnly);

Deprecated. Call the one-argument version of this method instead. If this method call used positiveOnly = true, check that the string does not begin with ‘-‘ before calling that version. If this method call used integersOnly = true, check that the string does not contain ‘.’, ‘E’, or ‘e’ before calling that version.

Parses a number whose format follows the JSON specification (RFC 8259). The method uses a JSONOptions with all default properties except for a PreserveNegativeZero property of false.

Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (“.”, full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A text string representing a valid JSON number is not allowed to contain white space characters, including spaces.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns positive zero if the number is a zero that starts with a minus sign (such as “-0” or “-0.0”). Returns null if the parsing fails, including if the string is null or empty.

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    string str,
    bool integersOnly,
    bool positiveOnly,
    bool preserveNegativeZero);

Deprecated. Instead, call ParseJSONNumber(str, jsonoptions) with a JSONOptions that sets preserveNegativeZero to the desired value, either true or false. If this method call used positiveOnly = true, check that the string does not begin with ‘-‘ before calling that version. If this method call used integersOnly = true, check that the string does not contain ‘.’, ‘E’, or ‘e’ before calling that version.

Parses a number whose format follows the JSON specification (RFC 8259).

Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (“.”, full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A text string representing a valid JSON number is not allowed to contain white space characters, including spaces.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the string is null or empty.

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    string str,
    int offset,
    int count);

Parses a number whose format follows the JSON specification (RFC 8259) from a portion of a text string, and converts that number to a CBOR object.

Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (“.”, full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A text string representing a valid JSON number is not allowed to contain white space characters, including spaces.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the string is null or empty.

Exceptions:

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    string str,
    int offset,
    int count,
    PeterO.Cbor.JSONOptions options);

Parses a number whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.

Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (“.”, full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A text string representing a valid JSON number is not allowed to contain white space characters, including spaces.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the string is null or empty or count is 0 or less.

Exceptions:

### ParseJSONNumber

public static PeterO.Cbor.CBORObject ParseJSONNumber(
    string str,
    PeterO.Cbor.JSONOptions options);

Parses a number whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.

Roughly speaking, a valid JSON number consists of an optional minus sign, one or more basic digits (starting with 1 to 9 unless there is only one digit and that digit is 0), an optional decimal point (“.”, full stop) with one or more basic digits, and an optional letter E or e with an optional plus or minus sign and one or more basic digits (the exponent). A text string representing a valid JSON number is not allowed to contain white space characters, including spaces.

Parameters:

Return Value:

A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the string is null or empty.

Back to CBOR start page.