jsondec: JSON Decode

View source: R/base.R

jsondecR Documentation

JSON Decode

Description

Minimal JSON parser. Converts JSON to R objects with proper type handling.

Usage

jsondec(x)

Arguments

x

Character string or raw vector containing JSON data.

Details

This is a minimal implementation designed for parsing HTTP API responses.

Value

The corresponding R object, or an empty list for invalid input.

Type Mappings

  • Object {} -> named list

  • Array ⁠[]⁠ -> unnamed list

  • String -> character

  • Number -> numeric

  • true/false -> logical

  • null -> NULL

RFC 8259 Non-conformance

  • Invalid JSON returns an empty list instead of erroring.

  • Duplicate keys are preserved; R accessors ($, [[) return first match.

  • Non-standard number forms may be accepted (e.g., leading zeros, hexadecimal).

  • Invalid escape sequences are output literally (e.g., ⁠\\uZZZZ⁠ becomes "uZZZZ").

  • Incomplete Unicode escape sequences for emoji are tolerated.

  • Nesting depth is limited to 512 levels.

See Also

jsonenc()

Examples

jsondec('{"name": "John", "age": 30}')
jsondec('[1, 2, 3]')
jsondec('"a string"')
jsondec('123')
jsondec('true')


secretbase documentation built on Feb. 5, 2026, 9:09 a.m.