R/json-opts.R
yyjson_read_flag.Rd
This is a list of integer values used for setting flags on the yyjson
code directly. This is an ADVANCED option and should be used with caution.
yyjson_read_flag
An object of class list
of length 9.
Some of these settings overlap and conflict with code needed to handle the translation of JSON values to R.
opts_read_json(yyjson_read_flag = c(yyjson_read_flag$x, yyjson_read_flag$y, ...))
Default option (RFC 8259 compliant):
Read positive integer as uint64_t.
Read negative integer as int64_t.
Read floating-point number as double with round-to-nearest mode.
Read integer which cannot fit in uint64_t or int64_t as double.
Report error if double number is infinity.
Report error if string contains invalid UTF-8 character or BOM.
Report error on trailing commas, comments, inf and nan literals.
Read the input data in-situ.
This option allows the reader to modify and use input data to store string
values, which can increase reading speed slightly.
The caller should hold the input data before free the document.
The input data must be padded by at least YYJSON_PADDING_SIZE
bytes.
For example: "[1,2]"
should be "[1,2]\0\0\0\0"
, input length should be 5.
Stop when done instead of issuing an error if there's additional content after a JSON document. This option may be used to parse small pieces of JSON in larger data, such as "NDJSON"
Allow single trailing comma at the end of an object or array,
such as "[1,2,3,]"
Allow C-style single line and multiple line comments (non-standard).
Allow inf/nan number and literal, case-insensitive, such as 1e999, NaN, inf, -Infinity (non-standard).
Read all numbers as raw strings (value with "YYJSON_TYPE_RAW" type), inf/nan literal is also read as raw with "ALLOW_INF_AND_NAN" flag.
Allow reading invalid unicode when parsing string values (non-standard). Invalid characters will be allowed to appear in the string values, but invalid escape sequences will still be reported as errors. This flag does not affect the performance of correctly encoded strings. WARNING: Strings in JSON values may contain incorrect encoding when this option is used, you need to handle these strings carefully to avoid security risks.
Read big numbers as raw strings. These big numbers include integers that cannot be represented by "int64_t" and "uint64_t", and floating-point numbers that cannot be represented by finite "double". The flag will be overridden by "YYJSON_READ_NUMBER_AS_RAW" flag.
read_json_str(
'[12.3]',
opts = opts_read_json(yyjson_read_flag = yyjson_read_flag$YYJSON_READ_ALLOW_TRAILING_COMMAS)
)
#> [1] 12.3