Learn R Programming

loggit2 (version 2.3.1)

sanitizers: Sanitization for ndJSON.

Description

Sanitizer and unsanitizer are needed because the ndjson format requires that each line be a valid JSON object, thus special characters must be escaped. The functions worke in such a way that the concatenation unsanitizer(sanitizer()) corresponds to the identity function.

Usage

default_ndjson_sanitizer(string)

default_ndjson_unsanitizer(string)

Value

A character vector.

Arguments

string

A character vector.

Details

The default sanatizer and unsanatizer are based on the following mapping:

CharacterReplacement
\\\
"\"
\r\\r
\n\\n

Examples

Run this code
if (FALSE) {
  default_ndjson_sanitizer('This is \n an "example"')
  default_ndjson_unsanitizer('This is \\n an \\"example\\"')
}

Run the code above in your browser using DataLab