You should:
models = jsons.compact.map { |json| Klass.new(JSON.parse(json)) }
where Klass-ActiveRecord model class
EDIT
Based on the comments, you do not want to assign identifiers in bulk, this can really become awkward, it is better to leave the rails to generate it, rather than in bulk:
models = jsons.compact.map { |json| Klass.new(JSON.parse(json).except(:id, "id")) }
:id, "id" is that I'm not sure if the parsed JSON uses characters or strings as keys
source
share