1.1.6 • Published 5 years ago
json-pretty-html v1.1.6
json-pretty-html
Transforms a JSON object into an HTML string. Allows selecting a subset of the object and highlight it with a CSS class.
Usage
var json = {
"id": 2,
"name": "An ice sculpture",
"price": 12.50,
"tags": ["cold", "ice"],
"dimensions": {
"length": 7.0,
"width": 12.0,
"height": 9.5
},
"warehouseLocation": {
"latitude": -78.75,
"longitude": 20.4
}
};
var prettyHtml = require('json-pretty-html').default;
var html = prettyHtml(json, json.dimensions);
With a nice CSS, the result will be:
CSS
You can use the default 'darcula' like stylesheet.
Or you can define your own styles. See below the list of CSS classes used in the generated HTML:
CSS Class | Purpose |
---|---|
json-pretty | A div grouping several lines, delimited by the start/end of the object or the start/end of the selection |
json-selected | The current selection div, if any. Always associated with the json-pretty class. |
json-key | Object key, excluding double quotes |
json-string | String value, excluding double quotes |
json-number | Number value |
json-boolean | Boolean value |
1.1.6
5 years ago
1.2.0
6 years ago
1.1.5
6 years ago
1.1.4
6 years ago
1.1.3
6 years ago
1.1.2
6 years ago
1.1.1
6 years ago
1.1.0
6 years ago
1.0.2
7 years ago
1.0.1
7 years ago
1.0.0
7 years ago
0.1.15
7 years ago
0.1.14
7 years ago
0.1.13
7 years ago
0.1.12
7 years ago
0.1.11
7 years ago
0.1.10
7 years ago
0.1.9
7 years ago
0.1.8
7 years ago
0.1.6
7 years ago
0.1.5
7 years ago
0.1.4
7 years ago
0.1.3
7 years ago
0.1.2
7 years ago
0.1.0
7 years ago
0.0.0
7 years ago