powered by
Minimal JSON encoder. Converts an R object to a JSON string.
jsonenc(x)
A character string containing the JSON representation.
An R object to encode as JSON.
Named list -> object {}
{}
Unnamed list -> array []
[]
Character -> string (with escaping)
Numeric/integer -> number
Logical -> true/false
true
false
NULL, NA -> null
NULL
NA
null
Scalars (length 1) -> primitive value
Vectors (length > 1) -> array []
Unsupported types (e.g., functions) -> null
This is a minimal implementation designed for creating HTTP API request bodies.
jsondec()
jsonenc(list(name = "John", age = 30L)) jsonenc(list(valid = TRUE, count = NULL)) jsonenc(list(nested = list(a = 1, b = list(2, 3)))) jsonenc(list(nums = 1:3, strs = c("a", "b")))
Run the code above in your browser using DataLab