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(byte[])](#ParseJSONNumber_byte)
- Parses a number from a byte sequence whose format follows the JSON specification.[ParseJSONNumber(byte[], int, int)](#ParseJSONNumber_byte_int_int)
- 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.[ParseJSONNumber(byte[], int, int, PeterO.Cbor.JSONOptions)](#ParseJSONNumber_byte_int_int_PeterO_Cbor_JSONOptions)
- Parses a number from a byte sequence whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.[ParseJSONNumber(byte[], PeterO.Cbor.JSONOptions)](#ParseJSONNumber_byte_PeterO_Cbor_JSONOptions)
- Parses a number from a byte sequence whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.[ParseJSONNumber(char[])](#ParseJSONNumber_char)
- Parses a number from a sequence of char s whose format follows the JSON specification.[ParseJSONNumber(char[], int, int)](#ParseJSONNumber_char_int_int)
- 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.[ParseJSONNumber(char[], int, int, PeterO.Cbor.JSONOptions)](#ParseJSONNumber_char_int_int_PeterO_Cbor_JSONOptions)
- 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.[ParseJSONNumber(char[], PeterO.Cbor.JSONOptions)](#ParseJSONNumber_char_PeterO_Cbor_JSONOptions)
- 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.[ParseJSONNumber(string)](#ParseJSONNumber_string)
- Parses a number whose format follows the JSON specification.[ParseJSONNumber(string, bool, bool)](#ParseJSONNumber_string_bool_bool)
- 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.[ParseJSONNumber(string, bool, bool, bool)](#ParseJSONNumber_string_bool_bool_bool)
- 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.[ParseJSONNumber(string, int, int)](#ParseJSONNumber_string_int_int)
- 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.[ParseJSONNumber(string, int, int, PeterO.Cbor.JSONOptions)](#ParseJSONNumber_string_int_int_PeterO_Cbor_JSONOptions)
- Parses a number whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.[ParseJSONNumber(string, PeterO.Cbor.JSONOptions)](#ParseJSONNumber_string_PeterO_Cbor_JSONOptions)
- Parses a number whose format follows the JSON specification (RFC 8259) and converts that number to a CBOR object.
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:
- bytes: A byte sequence to parse as a JSON number.
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.
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:
-
bytes: A sequence of bytes to parse as a JSON number.
-
offset: An index, starting at 0, showing where the desired portion of bytes begins.
-
count: The length, in code units, of the desired portion of bytes (but not more than bytes ‘s length).
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:
-
System.ArgumentException: Either offset or count is less than 0 or greater than bytes ‘s length, or bytes ‘s length minus offset is less than count .
-
System.ArgumentNullException: The parameter bytes is null.
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:
-
bytes: A sequence of bytes to parse as a JSON number.
-
offset: An index, starting at 0, showing where the desired portion of bytes begins.
-
count: The length, in code units, of the desired portion of bytes (but not more than bytes ‘s length).
-
options: An object containing options to control how JSON numbers are decoded to CBOR objects. Can be null, in which case a JSONOptions object with all default properties is used instead.
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:
-
System.ArgumentNullException: The parameter bytes is null.
-
System.ArgumentException: Unsupported conversion kind.
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:
-
bytes: A sequence of bytes to parse as a JSON number.
-
options: An object containing options to control how JSON numbers are decoded to CBOR objects. Can be null, in which case a JSONOptions object with all default properties is used instead.
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.
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:
- chars: A sequence of
char
s to parse as a JSON number.
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.
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:
-
chars: A sequence of
char
s to parse as a JSON number. -
offset: An index, starting at 0, showing where the desired portion of chars begins.
-
count: The length, in code units, of the desired portion of chars (but not more than chars ‘s length).
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:
-
System.ArgumentException: Either offset or count is less than 0 or greater than chars ‘s length, or chars ‘s length minus offset is less than count .
-
System.ArgumentNullException: The parameter chars is null.
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:
-
chars: A sequence of
char
s to parse as a JSON number. -
offset: An index, starting at 0, showing where the desired portion of chars begins.
-
count: The length, in code units, of the desired portion of chars (but not more than chars ‘s length).
-
options: An object containing options to control how JSON numbers are decoded to CBOR objects. Can be null, in which case a JSONOptions object with all default properties is used instead.
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:
-
System.ArgumentNullException: The parameter chars is null.
-
System.ArgumentException: Unsupported conversion kind.
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:
-
chars: A sequence of
char
s to parse as a JSON number. -
options: An object containing options to control how JSON numbers are decoded to CBOR objects. Can be null, in which case a JSONOptions object with all default properties is used instead.
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.
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:
- str: A text string to parse as a JSON number.
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.
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:
-
str: A text string to parse as a JSON number.
-
integersOnly: If true, no decimal points or exponents are allowed in the string. The default is false.
-
positiveOnly: If true, only positive numbers are allowed (the leading minus is disallowed). The default is false.
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.
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:
-
str: A text string to parse as a JSON number.
-
integersOnly: If true, no decimal points or exponents are allowed in the string. The default is false.
-
positiveOnly: If true, the leading minus is disallowed in the string. The default is false.
-
preserveNegativeZero: If true, returns positive zero if the number is a zero that starts with a minus sign (such as “-0” or “-0.0”). Otherwise, returns negative zero in this case. The default is false.
Return Value:
A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the string is null or empty.
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:
-
str: A text string containing the portion to parse as a JSON number.
-
offset: An index, starting at 0, showing where the desired portion of str begins.
-
count: The length, in code units, of the desired portion of str (but not more than str ‘s length).
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:
-
System.ArgumentException: Either offset or count is less than 0 or greater than str ‘s length, or str ‘s length minus offset is less than count .
-
System.ArgumentNullException: The parameter str is null.
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:
-
str: A text string to parse as a JSON number.
-
offset: An index, starting at 0, showing where the desired portion of str begins.
-
count: The length, in code units, of the desired portion of str (but not more than str ‘s length).
-
options: An object containing options to control how JSON numbers are decoded to CBOR objects. Can be null, in which case a JSONOptions object with all default properties is used instead.
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:
-
System.ArgumentNullException: The parameter str is null.
-
System.ArgumentException: Unsupported conversion kind.
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:
-
str: A text string to parse as a JSON number.
-
options: An object containing options to control how JSON numbers are decoded to CBOR objects. Can be null, in which case a JSONOptions object with all default properties is used instead.
Return Value:
A CBOR object that represents the parsed number. Returns null if the parsing fails, including if the string is null or empty.