sanitizers: Sanitization for ndJSON.

sanitizersR Documentation

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)

Arguments

string

A character vector.

Details

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

Character Replacement
⁠\⁠ ⁠\\⁠
⁠"⁠ ⁠\"⁠
⁠\r⁠ ⁠\\r⁠
⁠\n⁠ ⁠\\n⁠

Value

A character vector.

Examples

## Not run: 
  default_ndjson_sanitizer('This is \n an "example"')
  default_ndjson_unsanitizer('This is \\n an \\"example\\"')

## End(Not run)


loggit2 documentation built on June 8, 2025, 10:26 a.m.