@jsonhero/json-infer-types-formatter
v0.0.6
Published
Get nicely formatted string values using inferred types
Downloads
22
Readme
JSON Infer Types Formatter
You can nicely format values, with inferred or explicitly specified types (using the @jsonhero/json.infer-types package).
Installation
$ npm install --save @jsonhero/json-infer-types-formatterGetting started
JavaScript:
const { format } = require("@jsonhero/json-infer-types-formatted");TypeScript:
import { format } from "@jsonhero/json-infer-types-formatted";format(1234.567); // => { simple: "1,234.567", html: "1,234.567" }
format(true); // => { simple: "True", html: "True" }
format(null); // => { simple: "Null", html: "Null" }
format([0, 1]); // => { simple: "[0,1]", html: "<code>[0,1]</code>" }
format({ name: "Matt" }); // => { simple: '{"name":"Matt"}', html: '<code>{"name":"Matt"}</code>' }
format("https://www.google.com"); // => { simple: "https://www.google.com", html: '<a href="https://www.google.com">https://www.google.com</a>' }