gpt4 book ai didi

json - Mysql 5.7 原生 json 支持 - json_insert 函数中的控制键顺序

转载 作者:行者123 更新时间:2023-12-04 12:04:56 25 4
gpt4 key购买 nike

我在使用 json_insert 函数插入时遇到了 json 键排序问题。

我有如下排序记录

“空运”、“空运 express ”

“CFR”、“成本加运费”

“FH”、“免费房子”

“联合国”、“联合国”

“UPS”、“联合包裹服务”

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

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

但我希望 json 按照我插入的顺序维护 key 。虽然我能感觉到它试图根据键的字符长度来保持顺序。但是我怎样才能摆脱按顺序排列的键。

最佳答案

这很可悲,但现在无法保持原始 key 的顺序。

Normalization, Merging, and Autowrapping of JSON Values

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.

关于json - Mysql 5.7 原生 json 支持 - json_insert 函数中的控制键顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38910924/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com