{"id":16987259,"url":"https://github.com/tanishiking/jpp","last_synced_at":"2025-03-22T15:30:50.412Z","repository":{"id":48916071,"uuid":"154969772","full_name":"tanishiking/jpp","owner":"tanishiking","description":"JSON Prettier Printer that occupies a minimal number of lines while pretty-printing given JSON.","archived":false,"fork":false,"pushed_at":"2021-07-05T20:43:45.000Z","size":39,"stargazers_count":56,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T05:50:06.613Z","etag":null,"topics":["go","golang","json","json-pretty","layout"],"latest_commit_sha":null,"homepage":"https://godoc.org/github.com/tanishiking/jpp","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tanishiking.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-27T13:51:15.000Z","updated_at":"2024-10-11T22:40:10.000Z","dependencies_parsed_at":"2022-09-26T20:20:54.496Z","dependency_job_id":null,"html_url":"https://github.com/tanishiking/jpp","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanishiking%2Fjpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanishiking%2Fjpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanishiking%2Fjpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanishiking%2Fjpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tanishiking","download_url":"https://codeload.github.com/tanishiking/jpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244978442,"owners_count":20541857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","json","json-pretty","layout"],"created_at":"2024-10-14T02:48:51.112Z","updated_at":"2025-03-22T15:30:50.157Z","avatar_url":"https://github.com/tanishiking.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jpp\n[![Build Status](https://travis-ci.org/tanishiking/jpp.svg?branch=master)](https://travis-ci.org/tanishiking/jpp) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/b43969558e8246b4a2e5167eff17f21d)](https://app.codacy.com/app/tanishiking/jpp?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=tanishiking/jpp\u0026utm_campaign=Badge_Grade_Dashboard)\n\nJSON Prettier Printer that occupies a minimal number of lines while pretty-printing given JSON, using [prettier](https://github.com/tanishiking/prettier) which is Go implementation of [\"Wadler's \"A Prettier Printer\"](http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf).\n\n`jpp` is quite useful when we want to pretty print the JSON whose each node has a lot of children scalar values.\n\n![screenshot from 2018-10-28 16-57-16](https://user-images.githubusercontent.com/9353584/47613438-bb96a700-dad2-11e8-872c-4309d4330aef.png)\nThis `example.json` cites from https://json.org/example.html\n\n## Instalation\n### Homebrew\n```\n$ brew install tanishiking/jpp/jpp\n```\n\n### Download binary from GitHub Releases\nhttps://github.com/tanishiking/jpp/releases\n\n### Build from source\n```\n$ go get -u github.com/tanishiking/jpp/cmd/jpp\n```\n\n### Develop\n```sh\n$ make build # build binary into ./bin/jpp\n$ make test # run all unit tests\n```\n\n## jpp command\n### Options\n- `-w`: width (default: your terminal width)\n  - Note that this command does not guarantee there are no lines longer than `width`\n  - It just attempts to keep lines within this length when possible.\n- `-i`: indent string (default: `'  '`)\n\n### Environment Variables\nWe can specify the color of output string using following environment variables\n\n- `JPP_NULL`\n- `JPP_BOOL`\n- `JPP_NUMBER`\n- `JPP_STRING`\n- `JPP_FIELDNAME`\n\nand builtin colors:\n\n- `black`\n- `red`\n- `green`\n- `brown`\n- `blue`\n- `magenta`\n- `cyan`\n- `gray`\n- `bold_black`\n- `bold_red`\n- `bold_green`\n- `bold_brown`\n- `bold_blue`\n- `bold_magenta`\n- `bold_cyan`\n- `bold_gray`\n\nFor example, `cat some.json | JPP_NUMBER=bold_red jpp`.\nIn addition, we can specify complicated styles using SGR code.\nSee: https://en.wikipedia.org/wiki/ANSI_escape_code\n\n```\n$ go get -u github.com/tanishiking/jpp/cmd/jpp\n$ cat numbers.json\n[\n  [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ],\n  [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ],\n  [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]\n]\n$ cat numbers.json | jpp -w 20\n[\n  [\n    1, 2, 3, 4, 5,\n    6, 7, 8, 9, 10\n  ],\n  [\n    1, 2, 3, 4, 5,\n    6, 7, 8, 9, 10,\n    11, 12, 13, 14,\n    15\n  ],\n  [\n    1, 2, 3, 4, 5,\n    6, 7, 8, 9, 10,\n    11, 12, 13, 14,\n    15, 16, 17, 18,\n    19, 20\n  ]\n]\n```\n\n## Package Usage\n```go\nimport (\n\t\"fmt\"\n\n\t\"github.com/tanishiking/jpp\"\n)\n\nfunc main() {\n\tjsonStr := `\n[\n  [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ],\n  [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ],\n  [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ]\n]\n`\n\tres, _ := jpp.Pretty(jsonStr, \"  \", 20, nil)\n\tfmt.Println(res)\n\t// [\n\t//   [\n\t//     1, 2, 3, 4, 5,\n\t//     6, 7, 8, 9, 10\n\t//   ],\n\t//   [\n\t//     1, 2, 3, 4, 5,\n\t//     6, 7, 8, 9, 10,\n\t//     11, 12, 13, 14,\n\t//     15\n\t//   ],\n\t//   [\n\t//     1, 2, 3, 4, 5,\n\t//     6, 7, 8, 9, 10,\n\t//     11, 12, 13, 14,\n\t//     15, 16, 17, 18,\n\t//     19, 20\n\t//   ]\n\t// ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanishiking%2Fjpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftanishiking%2Fjpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanishiking%2Fjpp/lists"}