yyjson_read_flag {yyjsonr}R Documentation

Advanced: Values for setting internal options directly on YYJSON library

Description

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.

Usage

yyjson_read_flag

Format

An object of class list of length 9.

Details

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, ...))

YYJSON_READ_NOFLAG

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.

YYJSON_READ_INSITU

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.

YYJSON_READ_STOP_WHEN_DONE

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"

YYJSON_READ_ALLOW_TRAILING_COMMAS

Allow single trailing comma at the end of an object or array, such as "[1,2,3,]"

YYJSON_READ_ALLOW_COMMENTS

Allow C-style single line and multiple line comments (non-standard).

YYJSON_READ_ALLOW_INF_AND_NAN

Allow inf/nan number and literal, case-insensitive, such as 1e999, NaN, inf, -Infinity (non-standard).

YYJSON_READ_NUMBER_AS_RAW

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.

YYJSON_READ_ALLOW_INVALID_UNICODE

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.

YYJSON_READ_BIGNUM_AS_RAW

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.

Examples

read_json_str(
   '[12.3]', 
   opts = opts_read_json(yyjson_read_flag = yyjson_read_flag$YYJSON_READ_ALLOW_TRAILING_COMMAS)
 )

[Package yyjsonr version 0.1.20 Index]