Giter Club home page Giter Club logo

pretty_json's Introduction

pretty_json

Reformats the json file as well as a fetches from URL.

Supports:

  • Linux
  • macOS

Installation

  • Clone the repo to your local machine:
 git clone https://github.com/yitbehisbro/pretty_json.git 
  • Change directory to pretty_json:
 cd pretty_json
  • Change the mode of file to executable:
 chmod u+x *
  • Execute the INSTALL file:
./INSTALL

Usage

Usage:

pretty [filename ... [filename ... [filename ...] ] ]

Example:

yitbe@ubuntu:~$ pretty abc.json cde.json fgh.json

Please wait...
Will be created at "reformated/abc.json"
Done.
--
Will be created at "reformated/cde.json"
Done.
--
Will be created at "reformated/fgh.json"
Done.
--
yitbe@ubuntu:~$

Usage:

yitbe@ubuntu:~$ pretty *.json 

Usage:

pretty URL 

Example:


yitbe@ubuntu:~$ curl https://www.reddit.com/r/python/hot.json
{"kind": "Listing", "data": {"after": "t3_11dpfze", "dist": 27, "modhash": "", "geo_filter": null, "children": [{"kind": "t3", "data": {"approved_at_utc": null, "subreddit": "Python", "selftext": "Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.", "author_fullname": "t2_145f96", "saved": false, "mod_reason_title": null, "gilded": 0, "clicked": false, "title": "Sunday Daily Thread: What's everyone working on this week?", "link_flair_richtext": [{"e": "text", "t": "Daily Thread"}], "subreddit_name_prefixed": "r/Python", ...
yitbe@ubuntu:~$
yitbe@ubuntu:~$ curl https://jsonplaceholder.typicode.com/users/1
{
  "id": 1,
  "name": "Leanne Graham",
  "username": "Bret",
  "email": "[email protected]",
  "address": {
    "street": "Kulas Light",
    "suite": "Apt. 556",
    "city": "Gwenborough",
    "zipcode": "92998-3874",
    "geo": {
      "lat": "-37.3159",
      "lng": "81.1496"
    }
  },
  "phone": "1-770-736-8031 x56442",
  "website": "hildegard.org",
  "company": {
    "name": "Romaguera-Crona",
    "catchPhrase": "Multi-layered client-server neural-net",
    "bs": "harness real-time e-markets"
  }
}yitbe@ubuntu:~$
yitbe@ubuntu:~$ pretty https://www.reddit.com/r/python/hot.json https://jsonplaceholder.typicode.com/users/1

Please wait...

Done.
Created at "url_to_json/2023-02-28-15-03-45.json"

Done.
Created at "url_to_json/2023-02-28-15-03-57.json"

Some files might not be reformated.
Please refer /home/user/reformated/ or
/home/user/url_to_json/ for more.
yitbe@ubuntu:~$
yitbe@ubuntu:~$ less url_to_json/2023-02-28-15-03-57.json                # https://jsonplaceholder.typicode.com/users/1

{
  "id": 1,
  "name": "Leanne Graham",
  "username": "Bret",
  "email": "[email protected]",
  "address": {
    "street": "Kulas Light",
    "suite": "Apt. 556",
    "city": "Gwenborough",
    "zipcode": "92998-3874",
    "geo": {
      "lat": "-37.3159",
      "lng": "81.1496"
    }
  },
  "phone": "1-770-736-8031 x56442",
  "website": "hildegard.org",
  "company": {
    "name": "Romaguera-Crona",
    "catchPhrase": "Multi-layered client-server neural-net",
    "bs": "harness real-time e-markets"
  }
}
url_to_json/2023-02-28-15-03-57.json (END)

yitbe@ubuntu:~$
yitbe@ubuntu:~$ less url_to_json/2023-02-28-15-03-45.json                  # https://www.reddit.com/r/python/hot.json

{
  "kind": "Listing",
  "data": {
    "after": "t3_11dza2n",
    "dist": 27,
    "modhash": "",
    "geo_filter": null,
    "children": [
      {
        "kind": "t3",
        "data": {
          "approved_at_utc": null,
          "subreddit": "Python",
          "selftext": "Tell /r/python what you're working on this week! You can be bragging, grousing, sharing your passion, or explaining your pain. Talk about your current project or your pet project; whatever you want to share.",
          "author_fullname": "t2_145f96",
          "saved": false,
          "mod_reason_title": null,
          "gilded": 0,
          "clicked": false,
          "title": "Sunday Daily Thread: What's everyone working on this week?",
          "link_flair_richtext": [
            {
              "e": "text",
              "t": "Daily Thread"
            }
          ],
          "subreddit_name_prefixed": "r/Python",
          "hidden": false,
          "pwls": 6,
          "link_flair_css_class": "daily-thread",
          "downs": 0,
          "thumbnail_height": null,
          "top_awarded_type": null,
          "hide_score": false,
          "name": "t3_11bzuxb",
          "quarantine": false,
          "link_flair_text_color": "light",
          "upvote_ratio": 1.0,
          "author_flair_background_color": "#7289da",
          "subreddit_type": "public",
          "ups": 3,
          "total_awards_received": 0,
url_to_json/2023-02-28-15-03-45.json

Output

The reformated json file will be saved on the directory

$PWD/reformated/
Fetches from URL will be saved in
$PWD/url_to_json/

pretty_json's People

Contributors

yitbehisbro avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.