ruby on rails - Save data from api request to db (JSON) -
i sending messages rail app through third party , track deliver details , store in database table.after sending messages third party post deliver details given url,i got response url like.
http://yourdomain.com/dlr/pushurl.php?data=%7b%22requestid%22%3a%22546b384ce51f469a2e8b4567%22%2c%22numbers%22%3a%7b%22911234567890%22%3a%7b%22date%22%3a%222014-11-18+17%3a45%3a59%22%2c%22status%22%3a1%2c%22desc%22%3a%22delivered%22%7d%7d%7d
like following format,
data={ "requestid":"546b384ce51f469a2e8b4567", "numbers":{ "911234567890":{ "date":"2014-11-18 17:45:59", "status":1, "desc":"delivered" }}}
i used following code in controller display data.
json = params["data"]["numbers"] puts json
but displays null. want save data database.is there gem used or other method good.am new ror.
your issue params["data"]
string, treating hash.
data = json.parse(params["data"]) puts data['numbers']
Comments
Post a Comment