【发布时间】:2016-12-29 06:21:09
【问题描述】:
我创建了带有 mysql(5.7.16) 后端的 Rails(3.2) 应用程序。我无法保存 json 数据,我有如下传递值,它显示错误,如
ActiveRecord::StatementInvalid - Mysql2::Error: 无效的 JSON 文本:“无效值。”在“shopping_cart_item_special_infos.special_info”列值的第 1 位。:插入
shopping_cart_item_special_infos(created_at,shopping_cart_checkout_option_id,special_info,updated_at)值('2016-12-29 06:08:52' , 141, '--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess\n\'201\': text1\n\'209\': \'623\'\n\'210\': \'625\ '\n\'211\': text2\n', '2016-12-29 06:08:52'): activerecord (3.2.21) lib/active_record/connection_adapters/abstract_adapter.rb:285:inrescue in log' activerecord (3.2.21) lib/active_record/connection_adapters/abstract_adapter.rb:280:inlog' newrelic_rpm (3.9.1.236) lib/new_relic/agent/instrumentation/active_record.rb:63:in `block in log_with_newrelic_i
{"201"=>"text1", "209"=>"623", "210"=>"625", "211"=>"text2"}
这里出了什么问题?
【问题讨论】:
-
在文本而非图像中添加错误消息
-
Deepak:我已经编辑了问题
-
这是你的确切 json 吗?你要存储哪个?
-
@Amruth:是的。我要存储上面的json。
-
@anandh 检查你的 json jsonlint.com 我认为它无效
标签: mysql ruby-on-rails json