ABSTRACT

JavaScript Object Notation (JSON) is a popular data-interchange format that JS uses to work with data. As it turns out, working with JSON in JS is somewhat similar to working with list()s in R; both are recursive and heterogeneous data structures that have similar semantics for accessing values. In JSON, there are three basic building blocks: objects, arrays, and primitive data types (e.g., number, string, Boolean, null, undefined). Loosely speaking, a JSON array is similar to a un-named list() in R and a JSON object is similar to an un-named list(). In JSON, unlike R, there is no distinction between a heterogeneous and homogeneous collection of data types. In JSON, there is no strict notion of a homogeneous collection, so working with JSON arrays is essentially like being forced to use list() in R. This subtle fact can lead to some surprising results when trying to serialize R vectors as JSON arrays.