blob: e24cd48a1c30f8f49ef55c96af06fc305bd2677b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/usr/bin/env ruby
$: << "../lib"
require 'sson'
raw = false
if ARGV.first == "-r"
ARGV.shift
raw = true
end
input = ARGF.read
begin
case input[0]
when "{", "[", '"'
if raw
puts SSON.generate(JSON.parse(input))
else
puts SSON.pretty_generate(JSON.parse(input))
end
else
if raw
puts JSON.generate(SSON.parse(input))
else
puts JSON.pretty_generate(SSON.parse(input))
end
end
rescue SSON::SSONError, JSON::JSONError => e
abort "error: " + e.message
end
|