Skip to content

Instantly share code, notes, and snippets.

@tacahiroy
Created October 30, 2012 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tacahiroy/3978212 to your computer and use it in GitHub Desktop.
Save tacahiroy/3978212 to your computer and use it in GitHub Desktop.
tiny JSON validator
#! 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