Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mycaule/patriarchy
Summarize JSON hierarchies only on values
https://github.com/mycaule/patriarchy
Last synced: 20 days ago
JSON representation
Summarize JSON hierarchies only on values
- Host: GitHub
- URL: https://github.com/mycaule/patriarchy
- Owner: mycaule
- License: apache-2.0
- Created: 2017-12-07T15:21:15.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-09T11:18:48.000Z (about 7 years ago)
- Last Synced: 2024-11-20T13:08:25.022Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Render nested hierarchies based only on valuesI wrote this library to pretty print JSON describing identify records. The code is inspired from [archy](https://github.com/substack/node-archy).
## Usage
You can use this as an alternative method to `JSON.stringify` when the fields name are obvious to the reader.
```javascript
console.log(JSON.stringify(obj, null, 2))
```
```
{
"name": "Katy Perry",
"description": "American singer-songwriter",
"image": {
"contentUrl": "http://t3.gstatic.com/images?q=tbn:ANd9GcQrlKFmaiEtUImNiuD_pqzHPjDcjF4yaRThSFMh-rYuB8snFUfk",
"url": "https://en.wikipedia.org/wiki/Katy_Perry"
},
"detailedDescription": {
"articleBody": "Katheryn Elizabeth Hudson, known professionally as Katy Perry, is an American singer and songwriter. After singing in church during her childhood, she pursued a career in gospel music as a teenager. ",
"url": "https://en.wikipedia.org/wiki/Katy_Perry",
"license": "https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License"
},"url": "http://www.katyperry.com/"
}
```#### JavaScript
```javascript
const patriarchy = require('patriarchy')
console.log(patriarchy(obj))
```
```
Katy Perry
│ American singer-songwriter
│ http://www.katyperry.com/
├─┐ http://t3.gstatic.com/images?q=tbn:ANd9GcQrlKFmaiEtUImNiuD_pqzHPjDcjF4yaRThSFMh-rYuB8snFUfk
│ │ https://en.wikipedia.org/wiki/Katy_Perry
└─┐ Katheryn Elizabeth Hudson, known professionally as Katy Perry, is an American singer and songwriter. After singing in church during her childhood, she pursued a career in gospel music as a teenager.
│ https://en.wikipedia.org/wiki/Katy_Perry
│ https://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License
```#### Command-line interface
Install the tool globally `npm install -g patriarchy` or use with `npx patriarchy` if this is available in your Node.js version.
```bash
$ patriarchy '{"a1": "hello", "b1": {"a2": "world", "b2": "!"}}'
hello
└─┐ world
│ !
```## Contributions
[Changes and improvements](https://github.com/mycaule/patriarchy/wiki) are welcome! Feel free to fork and open a pull request into `master`.
### Running the tests
You can lint the code and run all unit tests using that script.
```bash
npm test
```### License
`patriarchy` is licensed under the [Apache 2.0 License](https://github.com/mycaule/patriarchy/blob/master/LICENSE).## References
* [James Halliday - archy package](https://github.com/substack/node-archy)