MySQL 5.7本机JSON支持-json_insert函数中的控制键顺序 [英] Mysql 5.7 native json support - control keys order in json_insert function

查看:128
本文介绍了MySQL 5.7本机JSON支持-json_insert函数中的控制键顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用json_insert函数插入时,我面临json键排序的问题.

I am facing issues with json key ordering while inserting using json_insert function.

我有如下排序的记录

"AIR","AIR Express"

"AIR", "AIR Express"

"CFR",成本和运费"

"CFR", "Cost and Freight"

"FH",自由屋"

联合国",联合国"

"UPS",联合包裹服务"

"UPS", "United Parcel Service"

使用json_insert函数将上述记录转换为json后,我看到的结果如下

After converting the above records into json using json_insert function, I am seeing the results as below

{"FH":免费送货","UN":联合国","AIR":"AIR Express","CFR":成本和运费","UPS":联合包裹服务" }

{"FH":"Free house", "UN": "United Nations", "AIR": "AIR Express", "CFR": "Cost and Freight", "UPS": "United Parcel Service"}

但是我希望json保持插入顺序不变.虽然我可以感觉到它正在尝试根据按键的字符长度来保持顺序.但是我该如何摆脱以使键按顺序排列的问题.

but I want the json to maintain the keys in the order I am inserting. Though I could sense that it is trying to maintain the order based on the character length of keys. But how can I get rid to get the keys aligned in the order.

推荐答案

这很可惜,但是现在无法保持原始键的顺序.

That's sad, but at now is no way to keep original keys order.

JSON值的规范化,合并和自动包装

MySQL执行的规范化还对JSON对象的键进行排序(以提高查找效率).此排序的结果可能会更改,并且不能保证在各个发行版之间保持一致.此外,原始文档中的键,值或元素之间的多余空格也将被丢弃.

The normalization performed by MySQL also sorts the keys of a JSON object (for the purpose of making lookups more efficient). The result of this ordering is subject to change and not guaranteed to be consistent across releases. In addition, extra whitespace between keys, values, or elements in the original document is discarded.

这篇关于MySQL 5.7本机JSON支持-json_insert函数中的控制键顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆