MySQL5.7的json数据格式的问题

存储json格式到数据库,默认会改变键的顺序。把自动类型改为text,不会改变键的顺序。

post 提交json字符串数据(后台没有做处理,原样插入数据库):

{"charge_total":{"field_type":"text","value":"1000","value_operator":"elt"},"charge_today":{"field_type":"text","value":"100","value_operator":"elt"},"check_start_date_time":{"field_type":"date","value":"2019-04-25 00:00:00","value_operator":"elt"},"check_end_date_time":{"field_type":"date","value":"2019-05-10 00:00:00","value_operator":"elt"},"layer":{"field_type":"text","value":"2","value_operator":"elt"}}

最终数据库查看到的存储数据为:

{"layer": {"value": "2", "field_type": "text", "value_operator": "elt"}, "charge_today": {"value": "100", "field_type": "text", "value_operator": "elt"}, "charge_total": {"value": "1000", "field_type": "text", "value_operator": "elt"}, "check_end_date_time": {"value": "2019-05-10 00:00:00", "field_type": "date", "value_operator": "elt"}, "check_start_date_time": {"value": "2019-04-25 00:00:00", "field_type": "date", "value_operator": "elt"}}

存储数据库的字段类型为json,键的顺序有变化?字段类型由json修改为text键值的顺序没有了变化,奇怪的mysql为什么这么排序了,而且这也不是按自然的排序处理的

posted @ 2019-04-28 14:27  ncsb  阅读(1792)  评论(0编辑  收藏  举报