GithubHelp home page GithubHelp logo

dirty-json-cli's Introduction

dirty json cli

This tool wrap dirty-json into cli tool

Setup

git clone this repo

cd dirty-json-cli

npm install -g

Test

case 1

echo "{ test: 'this is a test'}" | dirty-json

case 2

# strip jsonp function wrapper:
tail -n +6  ./test/aws_price/pricing-elb.min.js | sed 's/callback(//' | sed 's/);//' 

# format to useful data !!
tail -n +6  ./test/aws_price/pricing-elb.min.js | sed 's/callback(//' | sed 's/);//' | dirty-json | jq -r "."
{
  "vers": 0.01,
  "config": {
    "currencies": [
      "USD"
    ],
    "rate": "perInstanceHour@1min",
    "regions": [
      {
        "region": "us-east-1",
        "types": [
          {
            "values": [
              {
                "prices": {
                  "USD": "0.025"
                },
                "rate": "perELBHour"
              },
              {
                "prices": {
                  "USD": "0.008"
                },
                "rate": "perGBProcessed"
              }
            ]
          }
        ]
      },
      {
        "region": "us-west-2",
        "types": [
          {
            "values": [
              {
                "prices": {
                  "USD": "0.025"
                },
                "rate": "perELBHour"
              },
              {
                "prices": {
                  "USD": "0.008"
                },
                "rate": "perGBProcessed"
              }
            ]
          }
        ]
      },
      {
        "region": "us-west-1",
        "types": [
          {
            "values": [
              {
                "prices": {
                  "USD": "0.028"
                },
                "rate": "perELBHour"
              },
              {
                "prices": {
                  "USD": "0.008"
                },
                "rate": "perGBProcessed"
              }
            ]
          }
        ]
      },
      {
        "region": "eu-west-1",
        "types": [
          {
            "values": [
              {
                "prices": {
                  "USD": "0.028"
                },
                "rate": "perELBHour"
              },
              {
                "prices": {
                  "USD": "0.008"
                },
                "rate": "perGBProcessed"
              }
            ]
          }
        ]
      },
      {
        "region": "eu-central-1",
        "types": [
          {
            "values": [
              {
                "prices": {
                  "USD": "0.030"
                },
                "rate": "perELBHour"
              },
              {
                "prices": {
                  "USD": "0.008"
                },
                "rate": "perGBProcessed"
              }
            ]
          }
        ]
      },
      {
        "region": "ap-southeast-1",
        "types": [
          {
            "values": [
              {
                "prices": {
                  "USD": "0.028"
                },
                "rate": "perELBHour"
              },
              {
                "prices": {
                  "USD": "0.008"
                },
                "rate": "perGBProcessed"
              }
            ]
          }
        ]
      },
      {
        "region": "ap-northeast-1",
        "types": [
          {
            "values": [
              {
                "prices": {
                  "USD": "0.027"
                },
                "rate": "perELBHour"
              },
              {
                "prices": {
                  "USD": "0.008"
                },
                "rate": "perGBProcessed"
              }
            ]
          }
        ]
      },
      {
        "region": "ap-southeast-2",
        "types": [
          {
            "values": [
              {
                "prices": {
                  "USD": "0.028"
                },
                "rate": "perELBHour"
              },
              {
                "prices": {
                  "USD": "0.008"
                },
                "rate": "perGBProcessed"
              }
            ]
          }
        ]
      },
      {
        "region": "ap-northeast-2",
        "types": [
          {
            "values": [
              {
                "prices": {
                  "USD": "0.025"
                },
                "rate": "perELBHour"
              },
              {
                "prices": {
                  "USD": "0.008"
                },
                "rate": "perGBProcessed"
              }
            ]
          }
        ]
      },
      {
        "region": "ap-south-1",
        "types": [
          {
            "values": [
              {
                "prices": {
                  "USD": "0.0266"
                },
                "rate": "perELBHour"
              },
              {
                "prices": {
                  "USD": "0.008"
                },
                "rate": "perGBProcessed"
              }
            ]
          }
        ]
      },
      {
        "region": "sa-east-1",
        "types": [
          {
            "values": [
              {
                "prices": {
                  "USD": "0.034"
                },
                "rate": "perELBHour"
              },
              {
                "prices": {
                  "USD": "0.011"
                },
                "rate": "perGBProcessed"
              }
            ]
          }
        ]
      },
      {
        "region": "us-gov-west-1",
        "types": [
          {
            "values": [
              {
                "prices": {
                  "USD": "0.032"
                },
                "rate": "perELBHour"
              },
              {
                "prices": {
                  "USD": "0.010"
                },
                "rate": "perGBProcessed"
              }
            ]
          }
        ]
      }
    ]
  }
}

Have Fun

Future Extension

Question

* Are there and high level command line wrapper that turns any package into cli ??

dirty-json-cli's People

Contributors

sanrope 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.