{"id":13447394,"url":"https://github.com/Javascipt/Jsome","last_synced_at":"2025-03-21T17:31:24.412Z","repository":{"id":46329854,"uuid":"43980160","full_name":"Javascipt/Jsome","owner":"Javascipt","description":":sparkles: Make your JSON look AWESOME","archived":false,"fork":false,"pushed_at":"2023-11-29T22:26:11.000Z","size":92,"stargazers_count":241,"open_issues_count":14,"forks_count":24,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-13T19:33:00.119Z","etag":null,"topics":["color","colors","json","json-objects"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/Javascipt.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-10-09T21:06:48.000Z","updated_at":"2024-02-11T11:28:31.000Z","dependencies_parsed_at":"2024-01-06T09:57:55.018Z","dependency_job_id":"a6338af2-bc61-493a-8b30-80755c5fba6b","html_url":"https://github.com/Javascipt/Jsome","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Javascipt%2FJsome","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Javascipt%2FJsome/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Javascipt%2FJsome/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Javascipt%2FJsome/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Javascipt","download_url":"https://codeload.github.com/Javascipt/Jsome/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244611324,"owners_count":20481175,"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":["color","colors","json","json-objects"],"created_at":"2024-07-31T05:01:16.379Z","updated_at":"2025-03-21T17:31:24.383Z","avatar_url":"https://github.com/Javascipt.png","language":"JavaScript","funding_links":[],"categories":["Packages","JavaScript","包","Command-line apps","目录","Output"],"sub_categories":["Command-line apps","命令行程序","命令行应用"],"readme":"Make your JSON objects look AWESOME!\n====================================\n\n![Jsome](https://api.travis-ci.org/Javascipt/Jsome.svg)\n![Jsome](https://david-dm.org/Javascipt/Jsome.svg)\n![Jsome](https://img.shields.io/npm/dm/jsome.svg)\n\n![Downloads stats](https://nodei.co/npm/jsome.png?downloadRank=true\u0026stars=true)\n\n![Jsome](https://raw.githubusercontent.com/Javascipt/Jsome/master/logo.png)\n\nThis package allows you to give style to your JSON on your console!\n\n## Installation :\n\n```bash\n  $ npm install jsome\n```\n\nif you need to use jsome as a command line, you may need to instal it globally\n\n```bash\n  $ [sudo] npm install -g jsome\n```\n\n## How does it work ?\n\n#### Command line :\n\nUsing jsome as a command line, you need to run the following command that takes the path to your json file as argument\n\n```bash\n  $ jsome /path/to/your/json/file.json\n  $ jsome [options] /path/to/your/json/file.json\n```\n\nYou can also send a json string through a pipe (`|`)\n\n```bash\n  $ cat /path/to/your/json/file.json | jsome\n```\n\nThe options available are :\n- `-c`: to enable or disable colors (defualt value: true)\n- `-l`: to enable or disable levels (default value: false)\n- `-s`: to specify the number of tabulation spaces (default value: 2)\n- `-r`: to specify valid JSON as output (default value: true)\n\nexamples :\n\n```bash\n  $ jsome -c false /path/to/your/file.json\n  $ jsome -c false -l true /path/to/your/file.json\n  $ jsome -s 4 /path/to/your/file.json\n```\n\n##### Module :\n\nOn your nodejs application, when you need to console.log a json object, all you need to do is to use the jsome function\n\n```javascript\n    var jsome = require('jsome');\n    jsome([{\"id\":1,\"email\":\"Khalid@Morocco.ma\",\"active\":true},{\"id\":2,\"email\":\"Someone@somewhere.com\",\"active\":false},{\"id\":3,\"email\":\"chinese@bamboo.tree\",\"active\":true}]);\n```\n\nThen your json object will be displayed on the console in a pretty format with Awsome colors !\nHere is the result :\n\n![jsome](https://raw.githubusercontent.com/Javascipt/Jsome/master/examples/example1.png)\n\nThe `jsome` function returns the object passed as argument so that when debugging, you can print the value of an object without having to change a lot on your code\n\n```javascript\n\n    // instead of \n    \n    var foo = {\n      bar : obj\n    }\n    jsome (obj);\n    \n    // you can do this :\n    \n    var foo = {\n      bar : jsome(obj)\n    }\n    \n```\n\nYou can add some points to show levels of elements... very helpful when you are dealing with complex json objects\n\n```javascript\n    jsome.level.show = true;\n```\n\n![jsome](https://raw.githubusercontent.com/Javascipt/Jsome/master/examples/example2.png)\n\nThe object `jsome.level` has as default value the following json :\n\n```javascript\n  jsome.level = {\n      'show'    : false\n    , 'char'    : '.'\n    , 'color'   : 'red'\n    , 'spaces'  : 2\n    , 'start'   : 0\n  }\n```\n\nYou can change the level char, its color ( [see chalk package](http://npmjs.org/package/chalk) ) and the number of spaces for each level.\n\nYou can also display your json starting from a specific level to avoid displaying your json starting from the extreme left. You can do that by changing the value `jsome.level.start`.\n\nYou can configure the colors of the displayed json by changing the values of the `jsome.colors` object which has as default these values.\n\n```javascript\n  jsome.colors = {\n      'num'   : 'cyan'    // stands for numbers\n    , 'str'   : 'magenta' // stands for strings\n    , 'bool'  : 'red'     // stands for booleans\n    , 'regex' : 'blue'    // stands for regular expressions\n    , 'undef' : 'grey'    // stands for undefined\n    , 'null'  : 'grey'    // stands for null\n    , 'attr'  : 'green'   // objects attributes -\u003e { attr : value }\n    , 'quot'  : 'yellow'  // strings quotes -\u003e \"...\"\n    , 'punc'  : 'yellow'  // commas seperating arrays and objects values -\u003e [ , , , ]\n    , 'brack' : 'yellow'  // for both {} and []\n  }\n```\n\nYou can not only use the color value as string but also you can use an array to specify the background color or you can make things look bold  ( [see chalk package for more details](http://npmjs.org/package/chalk) )\n\n\n```javascript\n  jsome.colors.bool  = ['green' , 'bgRed']\n  jsome.colors.attr  = ['green' , 'bold']\n  jsome.colors.quot  = ['yellow', 'bold']\n  jsome.colors.punc  = ['yellow', 'bold']\n  jsome.colors.brack = ['yellow', 'bold']\n```\n![jsome](https://raw.githubusercontent.com/Javascipt/Jsome/master/examples/example3.png)\n\n\nWhen you have a json as a string, instead of passing by `JSON.parse` function, you can just call the parse function of jsome\n\n```javascript\n  jsome(JSON.parse('[1,2,3]'));\n```\n\nbecomes:\n\n```javascript\n  jsome.parse('[1,2,3]');\n```\n\nIf you need to disable the colors:\n\n```javascript\n  jsome.params.colored = false;\n```\n\nIf you need JSON which pases linting:\n\n```javascript\n  jsome.params.lintable = true;\n```\n\nWhen you have a very long json to display, don't make your code blocking... you can enable the asynchronous mode.\n\n```javascript\n  jsome.params.async = true;\n\n  jsome(longJson, function () {\n      /* Your code here */\n  });\n```\n\nThe default value of `params` is:\n\n```javascript\n  jsome.params = {\n      'colored' : true\n    , 'async'   : false\n    , 'lintable': false\n  }\n```\n\nIn order to get the colored string without printing it on the console :\n\n```javascript\n   var coloredString = jsome.getColoredString(obj)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJavascipt%2FJsome","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJavascipt%2FJsome","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJavascipt%2FJsome/lists"}