1.0.1 • Published 5 years ago

json-pretty-html-fix v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Build Status Dependencies NPM Downloads MIT Node.js version

json-pretty-html-fix

This package exists to temporarily solve the json-pretty-html project error. When the json-pretty-html project solves this problem, there is no need to continue using the package.

Please don't install this package, the original author has fixed this error.

Whether the json-pretty-html project solves the problem status: true

error details: https://github.com/amelki/json-pretty-html/issues/7

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-fix').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 ClassPurpose
json-prettyA div grouping several lines, delimited by the start/end of the object or the start/end of the selection
json-selectedThe current selection div, if any. Always associated with the json-pretty class.
json-keyObject key, excluding double quotes
json-stringString value, excluding double quotes
json-numberNumber value
json-booleanBoolean value