Generates a DOM node with a human representation of the JSON/EDN encoded data. Based on the json.human.js library.
The library provides support for Clojure/Script.
(use 'json-html.core)
(edn->html {:foo [1 2 3] :bar "baz"})
(json->html "{\"foo\": [1, 2, 3], \"bar\": \"baz\"}")
The ClojureScript version has additional functions called edn->hiccup
and json->hiccup
, these can be used to generate Hiccup forms for use with other libraries such as Reagent.
A default CSS is provided in resources/json.human.css
and can be included as follows:
(ns foo
(:use json-html.core hiccup.page))
(spit "formatted.html"
(html5
[:head [:style (-> "json.human.css" clojure.java.io/resource slurp)]]
(edn->html [:foo "bar" :baz [1 2 3]])))
{
"name": "json.human",
"description": "Convert\n JSON to human readable\r HTML",
"author": "Mariano Guerra <mariano@marianoguerra.org>",
"tags": ["DOM", "HTML", "JSON", "Pretty Print"],
"version": "0.1.0",
"main": "json.human.js",
"license" : "MIT",
"dependencies": {
"crel": "1.0.0"
},
"repository": {
"type": "git",
"url": "git://github.com/marianoguerra/json.human.js.git"
},
"bugs": {
"url": "https://github.com/yogthos/json-html/issues"
},
"contributors": [],
"config": {
"what?": "this object is just to show some extra stuff",
"how?": ["add json.human.js", "add json.human.css", "???", "profit!"],
"customization?": ["customize the css prefix", "change the css file"],
"integer": 42,
"float": 12.3,
"bool": true,
"emptyString": "",
"emptyArray": [],
"emptyObject": {},
"htmlEntities": " <- trailing <em> & </em> and some html "
}
}
author | Mariano Guerra <mariano@marianoguerra.org> |
---|
bugs | |
---|
config | bool | true |
---|
customization? | 0 | customize the css prefix |
---|
1 | change the css file |
---|
|
---|
emptyArray |
|
---|
emptyObject |
|
---|
emptyString | |
---|
float | 12.3 |
---|
how? | 0 | add json.human.js |
---|
1 | add json.human.css |
---|
2 | ??? |
---|
3 | profit! |
---|
|
---|
htmlEntities | <- trailing <em> & </em> and some html |
---|
integer | 42 |
---|
what? | this object is just to show some extra stuff |
---|
|
---|
contributors |
|
---|
dependencies | |
---|
description | Convert
JSON to human readable
HTML |
---|
license | MIT |
---|
main | json.human.js |
---|
name | json.human |
---|
repository | type | git |
---|
url | git://github.com/marianoguerra/json.human.js.git |
---|
|
---|
tags | 0 | DOM |
---|
1 | HTML |
---|
2 | JSON |
---|
3 | Pretty Print |
---|
|
---|
version | 0.1.0 |
---|
MIT