R: A simple JSON serializer

tojson {xfun} | R Documentation

## A simple JSON serializer

### Description

A JSON serializer that only works on a limited types of R data (`NULL`, lists, logical scalars, character/numeric vectors). The function `json_vector()` converts an atomic R vector to JSON.

### Usage

    tojson(x)

    json_vector(x, to_array = FALSE, quote = TRUE)

### Arguments

`x` | An R object.
`to_array` | Whether to convert a vector to a JSON array (use `[]`).
`quote` | Whether to double quote the elements.

### Value

A character string.

### Examples

    library(xfun)
    tojson(NULL)
    tojson(1:10)
    tojson(TRUE)
    tojson(FALSE)
    cat(tojson(list(a = 1, b = list(c = 1:3, d = "abc"))))
    cat(tojson(list(c("a", "b"), 1:5, TRUE)))

[Package xfun version 0.1 Index]