Comments (3)
mysqld测试结果
mysql> SELECT JSON_OBJECT('id', 123, 'name', 'polardb-x');
+---------------------------------------------+
| JSON_OBJECT('id', 123, 'name', 'polardb-x') |
+---------------------------------------------+
| {"id": 123, "name": "polardb-x"} |
+---------------------------------------------+
1 row in set (0.00 sec)
from polardbx-sql.
polardbx-optimizer\src\main\java\com\alibaba\polardbx\optimizer\core\function\calc\scalar\json\JsonObject.java
对应源码,生fastjson成json时会有顺序,没找到怎么改变设置顺序
@Override
public Object compute(Object[] args, ExecutionContext ec) {
if (args.length % 2 != 0) {
throw JsonParserException.wrongParamCount(getFunctionNames()[0]);
}
Map<String, Object> resultJson = Maps.newHashMap();
for (int i = 0; i < args.length; i += 2) {
if (args[i] == null) {
throw new JsonParserException("JSON documents may not contain NULL member names.");
}
if (i + 1 < args.length) {
resultJson.put(DataTypeUtil.convert(operandTypes.get(i), DataTypes.StringType, args[i]), args[i + 1]);
} else {
throw JsonParserException.wrongParamCount(getFunctionNames()[0]);
}
}
return JSON.toJSONString(resultJson);
}
from polardbx-sql.
关于MySQL 对 json_object输出顺序的描述:https://dev.mysql.com/doc/refman/8.0/en/json.html#json-normalization
To make lookups more efficient, MySQL also sorts the keys of a JSON object. You should be aware that the result of this ordering is subject to change and not guaranteed to be consistent across releases.
MySQL会对 JSON对象的key进行排序,但是不保证这个顺序在每个发行版都是一致的。
而PolarDB-X中调用了FastJson的接口,底层com.alibaba.fastjson.serializer.MapSerializer 是基于HashMap的遍历,这个同样也是不保证顺序的。
from polardbx-sql.
Related Issues (20)
- [WeeklyReport] Weekly report for polardbx-sql 10/23/2023 to 10/30/2023
- [WeeklyReport] Weekly report for polardbx-sql 10/30/2023 to 11/6/2023
- 分表的笛卡尔积SQL改写 HOT 1
- [WeeklyReport] Weekly report for polardbx-sql 11/6/2023 to 11/13/2023
- [WeeklyReport] Weekly report for polardbx-sql 11/13/2023 to 11/20/2023
- K8S operator webhook error x509: certificate is not valid for any names HOT 5
- [WeeklyReport] Weekly report for polardbx-sql 11/20/2023 to 11/27/2023
- [WeeklyReport] Weekly report for polardbx-sql 11/27/2023 to 12/4/2023
- [WeeklyReport] Weekly report for polardbx-sql 12/4/2023 to 12/11/2023
- [WeeklyReport] Weekly report for polardbx-sql 12/11/2023 to 12/18/2023
- [WeeklyReport] Weekly report for polardbx-sql 12/18/2023 to 12/25/2023
- [WeeklyReport] Weekly report for polardbx-sql 12/25/2023 to 1/1/2024
- [WeeklyReport] Weekly report for polardbx-sql 1/1/2024 to 1/8/2024
- Error from server (InternalError): error when creating "polardb-x.yaml": Internal error occurred: failed calling webhook "polardbxcluster-mutate.polardbx.aliyun.com": failed to call webhook: the server is currently unable to handle the request
- [WeeklyReport] Weekly report for polardbx-sql 1/8/2024 to 1/15/2024
- [WeeklyReport] Weekly report for polardbx-sql 1/15/2024 to 1/22/2024
- [WeeklyReport] Weekly report for polardbx-sql 1/22/2024 to 1/29/2024
- [WeeklyReport] Weekly report for polardbx-sql 1/29/2024 to 2/5/2024
- Windows 使用PXD安装PolarDB-X报 '--initialize-insecure']' returned non-zero exit status 1. HOT 14
- 银河麒麟v10启动报错
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polardbx-sql.