EVOLUTION-MANAGER
Edit File: tojson.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: A simple JSON serializer</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for tojson {xfun}"><tr><td>tojson {xfun}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>A simple JSON serializer</h2> <h3>Description</h3> <p>A JSON serializer that only works on a limited types of R data (<code>NULL</code>, lists, logical scalars, character/numeric vectors). A character string of the class <code>JS_EVAL</code> is treated as raw JavaScript, so will not be quoted. The function <code>json_vector()</code> converts an atomic R vector to JSON. </p> <h3>Usage</h3> <pre> tojson(x) json_vector(x, to_array = FALSE, quote = TRUE) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>An R object.</p> </td></tr> <tr valign="top"><td><code>to_array</code></td> <td> <p>Whether to convert a vector to a JSON array (use <code>[]</code>).</p> </td></tr> <tr valign="top"><td><code>quote</code></td> <td> <p>Whether to double quote the elements.</p> </td></tr> </table> <h3>Value</h3> <p>A character string. </p> <h3>See Also</h3> <p>The <span class="pkg">jsonlite</span> package provides a full JSON serializer. </p> <h3>Examples</h3> <pre> 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))) # the class JS_EVAL is originally from htmlwidgets::JS() JS = function(x) structure(x, class = "JS_EVAL") cat(tojson(list(a = 1:5, b = JS("function() {return true;}")))) </pre> <hr /><div style="text-align: center;">[Package <em>xfun</em> version 0.16 <a href="00Index.html">Index</a>]</div> </body></html>