【发布时间】:2021-11-14 08:53:29
【问题描述】:
我们如何创建一个接收json 作为输入并返回相同json 的mysql 函数?
这基本上是我想在新功能中发生的事情......
json_extract( # Extract the json object by its path
jsonComponents,
substring_index( # Unquote and trim for receiving path to the object instead to its attribute
json_unquote(
json_search( # Find the path to an specific json object by a value
jsonComponents,
'one',
'com.parallelorigin.code.ecs.components.Identity'
)
),
'.', 1)
),
我试过这样,但它给了我一个不同步的错误或类似的错误。而且我不知道为什么......
DELIMITER //
DROP FUNCTION IF EXISTS json_extract_object_by_value;
CREATE FUNCTION json_extract_object_by_value(x json) RETURNS json
BEGIN
RETURN JSON("10","10")
END//
DELIMITER ;
我们究竟如何在 mysql 中创建一个 json 函数?我们如何传递 json 并从中返回 json?
【问题讨论】:
-
我不明白这个问题。如果要返回相同的 JSON,只需使用
RETURN x; -
什么是
jsonComponents?