You can use the json library
json
You can then do:
jsonArray = [{"content":"1D","createdTime":"09-06-2011 00:59"},
{"content":"2D","createdtime":"09-06-2011 08:00"}]
objArray = JSON.parse(jsonArray)
In response to your comment, you can do this, as long as your JSON fits your model
objArray.each do |object|
# This is a hash object so now create a new one.
newMyObject = MyObject.new(object)
newMyObject.save # You can do validation or any other processing around here.
end
No comments:
Post a Comment