产品动态
公告
json_add(key,data)
参数名称 | 参数描述 | 参数类型 | 是否必须 | 参数默认值 | 参数取值范围 |
key | json 对应的 key | string | 是 | - | - |
data | 补充新的节点 | dict | 是 | - | - |
{"content": "{\\"a\\":{\\"b\\":{\\"c\\":\\"cc\\"}}}"}
json_add("content", {"a":{"b":{"d":"dd"}}})
{"content": "{\\"a\\":{\\"b\\":{\\"c\\":\\"cc\\",\\"d\\":\\"dd\\"}}}"}
json_edit("result", path="", key="",value="333",index=1,mode="edit")
参数名称 | 参数描述 | 参数类型 | 是否必须 | 参数默认值 | 参数取值范围 |
field | 嵌套 json 对应的 key | string | 是 | - | - |
path | string | 否 | - | - | |
key | 需要删除或修改的目标字段,当对数组元素操作时,无需填写 | string | 否 | - | - |
value | 需要设定的新值,修改值时才需要填写 | string | 否 | - | - |
index | 对数组操作时填写该字段,数组元素从1开始 | number | 否 | 0 | - |
mode | 模式。修改:edit,删除:move。默认 move | string | 否 | move | - |
{"content":"{\\"p9\\":[\\"0.0\\",\\"0.0\\"],\\"p18\\":\\"CN\\"}","time":"1650440364"}
json_edit("content", path="", key="p18", value="hello", mode="edit")
{"content":"{\\"p9\\":[\\"0.0\\",\\"0.0\\"],\\"p18\\":\\"hello\\"}", "time":"1650440364"}
{"content":"{\\"p9\\":[\\"0.0\\",\\"0.0\\"],\\"p18\\":\\"CN\\",\\"info\\":{\\"province\\":\\"hubei\\",\\"geo\\":{\\"long\\":\\"111\\",\\"lati\\":\\"222\\"}}}","time":"1650440364"}
json_edit("content", path="info.geo", key="long", value="333", mode="edit")
{"content":"{\\"p9\\":[\\"0.0\\",\\"0.0\\"],\\"p18\\":\\"CN\\",\\"info\\":{\\"province\\":\\"hubei\\",\\"geo\\":{\\"long\\":\\"333\\",\\"lati\\":\\"222\\"}}}","time":"1650440364"}
{"content":"{\\"p9\\":[\\"0.0\\",\\"0.0\\"],\\"p18\\":\\"CN\\",\\"info\\":{\\"province\\":\\"hubei\\",\\"geo\\":{\\"long\\":\\"111\\",\\"lati\\":\\"222\\"}}}","time":"1650440364"}
json_edit("content", path="", key="p18", mode="move")
{"content":"{\\"p9\\":[\\"0.0\\",\\"0.0\\"],\\"info\\":{\\"province\\":\\"hubei\\",\\"geo\\":{\\"long\\":\\"111\\",\\"lati\\":\\"222\\"}}}","time":"1650440364"}
{"content":"{\\"p9\\":[\\"0.0\\",\\"0.0\\"],\\"p18\\":\\"CN\\",\\"info\\":{\\"province\\":[\\"hello\\",\\"world\\"],\\"geo\\":{\\"long\\":[\\"1.0\\",\\"2.0\\"],\\"lati\\":\\"222\\"}}}","time":"1650440364"}
json_edit("content", path="info.province", index=1, mode="move")
{"content":"{\\"p9\\":[\\"0.0\\",\\"0.0\\"],\\"p18\\":\\"CN\\",\\"info\\":{\\"province\\":[\\"world\\"],\\"geo\\":{\\"long\\":[\\"1.0\\",\\"2.0\\"],\\"lati\\":\\"222\\"}}}","time":"1650440364"}
json_select(data, jmes="")
参数名称 | 参数描述 | 参数类型 | 是否必须 | 参数默认值 | 参数取值范围 |
data | 字段值,可以通过其他函数提取字段值 | string | 是 | - | - |
jmes | string | 是 | - | - |
{"field": "{\\"a\\":{\\"b\\":{\\"c\\":{\\"d\\":\\"success\\"}}}}", "status": "500"}
fields_set("message", json_select(v("field"), jmes="a.b.c.d"))
{"field":"{\\"a\\":{\\"b\\":{\\"c\\":{\\"d\\":\\"success\\"}}}}","message":"success","status":"500"}
json_update(json值, key1, value1,key2, value2)
参数名称 | 参数描述 | 参数类型 | 是否必须 | 参数默认值 | 参数取值范围 |
field | json 对应的 key | string | 是 | - | - |
可变参 | 添加进 json 的 key value 对 | string | 是 | - | - |
{"data": "{\\"c\\":\\"d\\"}"}
json_update("data", "11", "22")
{"data":"{\\"11\\":\\"22\\",\\"c\\":\\"d\\"}"}
{"data": "{\\"c\\":\\"d\\"}","name": "测试","timestamp": 1734567890,"status": true}
json_update("data", "11", "11", "22", "22", "33")
{"data":"{"11":"11","22":"22","c":"d"}","name":"测试","status":"true","timestamp":"1734567890"}
xml_to_json(data)
参数名称 | 参数描述 | 参数类型 | 是否必须 | 参数默认值 | 参数取值范围 |
data | 字段值 | string | 是 | - | - |
{"xml_field": "<note><to>B</to><from>A</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>", "status": "500"}
fields_set("json_field", xml_to_json(v("xml_field")))
{"xml_field":"<note><to>B</to><from>A</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>","json_field":"{\\"to\\":\\"B\\",\\"from\\":\\"A\\",\\"heading\\":\\"Reminder\\",\\"body\\":\\"Don't forget me this weekend!\\"}","status":"500"}
json_to_xml(data)
参数名称 | 参数描述 | 参数类型 | 是否必须 | 参数默认值 | 参数取值范围 |
data | 字段值 | string | 是 | - | - |
{"json_field":"{\\"to\\":\\"B\\",\\"from\\":\\"A\\",\\"heading\\":\\"Reminder\\",\\"body\\":\\"Don't forget me this weekend!\\"}", "status": "200"}
fields_set("xml_field", json_to_xml(v("json_field")))
{"json_field":"{\\"to\\":\\"B\\",\\"from\\":\\"A\\",\\"heading\\":\\"Reminder\\",\\"body\\":\\"Don't forget me this weekend!\\"}","xml_field":"<ObjectNode><to>B</to><from>A</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></ObjectNode>","status":"200"}
if_json(data)
参数名称 | 参数描述 | 参数类型 | 是否必须 | 参数默认值 | 参数取值范围 |
data | 字段值 | string | 是 | - | - |
{"condition":"{\\"a\\":\\"b\\"}","status":"500"}
t_if(if_json(v("condition")), fields_set("new", 1))
{"new":"1","condition":"{\\"a\\":\\"b\\"}","status":"500"}
{"condition":"haha","status":"500"}
t_if(if_json(v("condition")), fields_set("new", 1))
{"condition":"haha","status":"500"}
array_get(数组,下标位置)
参数名称 | 参数描述 | 参数类型 | 是否必须 | 参数默认值 | 参数取值范围 |
数组 | 数组 | string | 是 | - | - |
下标位置 | 取数组第几个值 | int | 是 | - | - |
{"field1": "[1,2,3]"}
fields_set("field2", array_get(v("field1"), 0))
{"field1":"[1,2,3]","field2":"1"}
{"field1": "['tom','jerry','bobo']"}
fields_set("field2", array_get(v("field1"), 0))
{"field1":"['tom','jerry','bobo']","field2":"tom"}
文档反馈