Converts R object into JSON objects and vice-versa