json2html | R Documentation |
Render a formatted JSON string in HTML.
json2html( json, outfile = NULL, pandoc = FALSE, style = paste0("background-color: #051C55; color: #E76900; ", "font-size: 15px; font-weight: bold; margin: 0; ", "white-space: pre-wrap; outline: #051C55 solid 10px;"), keyColor = "crimson", numberColor = "chartreuse", stringColor = "lightcoral", trueColor = "#00cc00", falseColor = "#ff8080", nullColor = "cornflowerblue" )
json |
a JSON string or a path to a JSON file |
outfile |
either a path to a html file, or |
pandoc |
Boolean, whether to use pandoc |
style |
some CSS for the container, only if |
keyColor |
color of the keys, only if |
numberColor |
color of the numbers, only if |
stringColor |
color of the strings, only if |
trueColor |
color of the |
falseColor |
color of the |
nullColor |
color of the |
Nothing if outfile
is not NULL
, otherwise the HtML
as a character string.
library(cppcheckR) xml <- system.file("extdata", "order-schema.xml", package = "xml2") json <- xml2json(xml) html <- json2html(json) library(htmltools) if(interactive()){ browsable(HTML(html)) } # with pandoc html <- json2html(json, pandoc = TRUE) if(interactive()){ browsable(HTML(html)) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.