Skip to content

Instantly share code, notes, and snippets.

@xxxazxxx
Created September 20, 2013 14:02
Show Gist options
  • Save xxxazxxx/6638050 to your computer and use it in GitHub Desktop.
Save xxxazxxx/6638050 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"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment