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: Convert R To JSON</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 {rjson}"><tr><td>toJSON {rjson}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Convert R To JSON</h2> <h3>Description</h3> <p> Convert an R object into a corresponding JSON object. </p> <p>***Lists with unnamed components are not currently supported*** </p> <h3>Usage</h3> <pre>toJSON( x, indent=0, method="C" )</pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>a vector or list to convert into a JSON object</p> </td></tr> <tr valign="top"><td><code>indent</code></td> <td> <p>an integer specifying how much indentation to use when formatting the JSON object; if 0, no pretty-formatting is used</p> </td></tr> <tr valign="top"><td><code>method</code></td> <td> <p>use the <code>C</code> implementation, or the older slower (and one day to be depricated) <code>R</code> implementation</p> </td></tr> </table> <h3>Value</h3> <p>a string containing the JSON object</p> <h3>See Also</h3> <p><code><a href="fromJSON.html">fromJSON</a></code> </p> <h3>Examples</h3> <pre> x <- list( alpha = 1:5, beta = "Bravo", gamma = list(a=1:3, b=NULL), delta = c(TRUE, FALSE) ) json <- toJSON( x ) fromJSON( json ) #named vectors are treated as JSON objects (lists) toJSON(islands[1:4]) #data.frames must be converted into a list before converting into JSON plot(cars, pch=2) json_cars <- toJSON(as.list(cars)) points( data.frame( fromJSON( json_cars ) ), col="red", pch=3 ) #special R types are encoded as strings testString <- c(1,2,3,4,NA,NaN,Inf,8,9); toJSON(testString); </pre> <hr /><div style="text-align: center;">[Package <em>rjson</em> version 0.2.20 <a href="00Index.html">Index</a>]</div> </body></html>