Skip to content

Instantly share code, notes, and snippets.

@flori
Created September 20, 2013 10:39
Show Gist options
  • Save flori/6635785 to your computer and use it in GitHub Desktop.
Save flori/6635785 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'json'
r = ''
for line in DATA
line.gsub!(/^(\s*"[^=]+":\s*")(.*?)(",\s*)$/) {
b, m, a = $~.captures
"#{b}#{m.gsub('"', '\\"')}#{a}"
}
puts line
r << line
end
p JSON.parse(r)
__END__
{
"key1": "foo"bar"baz",
"key2": "foo",
"key3": "foo"bar"",
"key4": "bar"
}
@xxxazxxx
Copy link

@flori I'm unable to PREPROCESS the Tidy JSON. I request you to help me out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment