Created
October 30, 2012 03:57
-
-
Save tacahiroy/3978212 to your computer and use it in GitHub Desktop.
tiny JSON validator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! ruby | |
require "rubygems" | |
require "yajl" | |
exit 0 if ARGV.length == 0 | |
begin | |
lines = ARGF.read | |
Yajl::Parser.new.parse(lines) | |
exit 0 | |
rescue Yajl::ParseError => e | |
msg, code, marker = e.message.split(/\n/) | |
puts msg, code, marker | |
exit 1 | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment