https://github.com/lancejpollard/pretty-compact-json.js
Prettify JSON in a more compact, human-readable way
https://github.com/lancejpollard/pretty-compact-json.js
javascript-library json prettify pretty-print
Last synced: 2 months ago
JSON representation
Prettify JSON in a more compact, human-readable way
- Host: GitHub
- URL: https://github.com/lancejpollard/pretty-compact-json.js
- Owner: lancejpollard
- Created: 2022-11-15T08:58:53.000Z (over 3 years ago)
- Default Branch: make
- Last Pushed: 2022-11-15T10:57:52.000Z (over 3 years ago)
- Last Synced: 2025-01-29T01:59:32.898Z (over 1 year ago)
- Topics: javascript-library, json, prettify, pretty-print
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Pretty Compact JSON
JavaScript library for prettifying JSON in a compact, more human-readable way.
```
yarn add @lancejpollard/pretty-compact-json.js
```
```js
const prettify1 = require("@lancejpollard/pretty-compact-json.js/1");
const prettify2 = require("@lancejpollard/pretty-compact-json.js/2");
```
Given this input:
```json
{
"a": [
{
"name": "foo",
"value": 123
}
],
"b": {
"x": [1, 2, 3],
"y": {
"z": 10
},
"w": {
"a": {
"b": {
"c": 456,
"d": 789,
"e": "hello world",
"f": { "g": true, "p": [1, { "q": 2, "v": "bar" }, 3] }
}
}
}
},
"c": [{ "a": { "b": 111, "c": 222 } }, 1, null, { "x": 3 }],
"d": "random"
}
```
```js
prettify1(input);
```
```json
{
"a": [
{
"name": "foo",
"value": 123 } ],
"b": {
"x": [ 1, 2, 3 ],
"y": {
"z": 10 },
"w": {
"a": {
"b": {
"c": 456,
"d": 789,
"e": "hello world",
"f": {
"g": true,
"p": [
1,
{
"q": 2,
"v": "bar" },
3 ] } } } } },
"c": [
{
"a": {
"b": 111,
"c": 222 } },
1,
null,
{
"x": 3 } ],
"d": "random" }
```
```js
prettify2(input)
```
```json
{ "a": [ { "name": "foo",
"value": 123 } ],
"b": { "x": [ 1, 2, 3 ],
"y": { "z": 10 },
"w": { "a": { "b": { "c": 456,
"d": 789,
"e": "hello world",
"f": { "g": true,
"p": [ 1,
{ "q": 2,
"v": "bar" },
3 ] } } } } },
"c": [ { "a": { "b": 111,
"c": 222 } },
1,
null,
{ "x": 3 } ],
"d": "random" }
```