Skip to content

Instantly share code, notes, and snippets.

@weiland
Created July 15, 2015 13:33
Show Gist options
  • Save weiland/9328be063524b0f2c942 to your computer and use it in GitHub Desktop.
Save weiland/9328be063524b0f2c942 to your computer and use it in GitHub Desktop.
Read in json dump of an ActiveRecord object in ruby

read in json dump

Having a Dump of DataSample in json. (maybe replaceing backslashes :s/\\//g (vim))

file = File.read('my_data.json')
json = JSON.parse(file)

json.each { |entry| DataSample.new.form_json(entry.to_json.to_s).save }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment