json_object

description

Syntax

VARCHAR json_object(VARCHAR,...)

生成一个包含指定Key-Value对的json object, 当Key值为NULL或者传入参数为奇数个时,返回异常错误

example

  1. MySQL> select json_object();
  2. +---------------+
  3. | json_object() |
  4. +---------------+
  5. | {} |
  6. +---------------+
  7. MySQL> select json_object('time',curtime());
  8. +--------------------------------+
  9. | json_object('time', curtime()) |
  10. +--------------------------------+
  11. | {"time": "10:49:18"} |
  12. +--------------------------------+
  13. MySQL> SELECT json_object('id', 87, 'name', 'carrot');
  14. +-----------------------------------------+
  15. | json_object('id', 87, 'name', 'carrot') |
  16. +-----------------------------------------+
  17. | {"id": 87, "name": "carrot"} |
  18. +-----------------------------------------+
  19. MySQL> select json_object('username',null);
  20. +---------------------------------+
  21. | json_object('username', 'NULL') |
  22. +---------------------------------+
  23. | {"username": NULL} |
  24. +---------------------------------+

keyword

json_object