更新时间:2023-09-09 14:27:40
您可以使用json库 json
You can use the json library json
您可以执行以下操作:
jsonArray = [{"content":"1D","createdTime":"09-06-2011 00:59"},
{"content":"2D","createdtime":"09-06-2011 08:00"}]
objArray = JSON.parse(jsonArray)
只要您的JSON适合您的模型,就可以对您的评论做出回应
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