jsonpp 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +12 -0
  2. data/bin/jsonpp +25 -0
  3. metadata +58 -0
@@ -0,0 +1,12 @@
1
+ JSON pretty printer
2
+ ===================
3
+
4
+ A stupid, 10 lines pretty printer. This one depends on multi_json.
5
+
6
+ ```
7
+ Usage:
8
+
9
+ $ curl http://some/api | jsonpp
10
+ or
11
+ $ jsonpp ./some/file.json
12
+ ```
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ require 'multi_json'
3
+
4
+ def main(file_path)
5
+ case file_path
6
+ when '-h', '--help'
7
+ puts "Usage: jsonpp [file]"
8
+ puts "Pretty-prints the given file or stdin"
9
+ when '-', nil
10
+ input = $stdin.read
11
+ else
12
+ input = File.read file_path
13
+ end
14
+
15
+ data = MultiJson.decode input
16
+
17
+ output = MultiJson.encode(data, :pretty => true)
18
+
19
+ puts output
20
+ rescue MultiJson::DecodeError => ex
21
+ $stderr.puts ex
22
+ exit 1
23
+ end
24
+
25
+ main(ARGV[0])
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jsonpp
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jonas Pfenniger
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-15 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: multi_json
16
+ requirement: &70306291142560 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70306291142560
25
+ description: A really small gem that prints your `curl` output nicely
26
+ email: jonas@pfenniger.name
27
+ executables:
28
+ - jsonpp
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - README.md
33
+ - bin/jsonpp
34
+ homepage: https://github.com/zimbatm/jsonpp
35
+ licenses: []
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ! '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 1.8.11
55
+ signing_key:
56
+ specification_version: 3
57
+ summary: Command-line JSON pretty-printer
58
+ test_files: []