第一次涉足 JSON 的世界,尝试从中提取数据,对我这个编程新手来说,有点小挑战!
在帮助文档里查看了「文本处理→提取 JSON 内容」的部分,但感觉那里的例子和我手头这个任务不太对口。我这边的数据结构好像更复杂一些,或者说,我需要的提取方式更特别一些。
我知道这可能是个小 Case,但对我来说真的挺重要。所以,如果哪位大侠能抽空丢个线索或者指导一下,我将不胜感激!🙏
任务详情如下:
步骤如下:
JSON如下:
[{
"id": "fUwa5gl4_nYQYKgoTNN9D",
"avatar": "gpt-bot",
"name": "第一项名字",
"context": [{
"id": "QysmITLIh7e5b3UcW3Fyh",
"date": "2024/3/25 22:53:36",
"role": "system",
"content": "第一项,内容1"
}, {
"id": "4KORdfSwb2pvuQfvlzOuo",
"date": "",
"role": "user",
"content": "第一项,内容2"
}],
"syncGlobalConfig": false,
"modelConfig": {
"model": "gpt-3.5-turbo-1106",
"temperature": 0.5,
"top_p": 1,
"max_tokens": 4000,
"presence_penalty": 0,
"frequency_penalty": 0,
"sendMemory": true,
"historyMessageCount": 6,
"compressMessageLengthThreshold": 2000,
"enableInjectSystemPrompts": true,
"template": "{{input}}"
},
"lang": "cn",
"builtin": false,
"createdAt": 1711340452431
}, {
"id": "DGrq_UMt2CCZdJqvhBboi",
"avatar": "gpt-bot",
"name": "第二项名字",
"context": [{
"id": "M8MRZ_KGlK_3HlfF_4wkw",
"date": "2024/3/25 12:20:58",
"role": "system",
"content": "第二项内容1"
}, {
"id": "4KORdfSwb2pvuQfvlzOuo",
"date": "",
"role": "user",
"content": "第二项内容2"
}],
"syncGlobalConfig": false,
"modelConfig": {
"model": "gpt-3.5-turbo-1106",
"temperature": 0.5,
"top_p": 1,
"max_tokens": 4000,
"presence_penalty": 0,
"frequency_penalty": 0,
"sendMemory": true,
"historyMessageCount": 6,
"compressMessageLengthThreshold": 2000,
"enableInjectSystemPrompts": true,
"template": "{{input}}"
},
"lang": "cn",
"builtin": false,
"createdAt": 1711340452431
}, {
"id": "N6itoPkkNOhDjA0mNDWSC",
"avatar": "gpt-bot",
"name": "第三项名字",
"context": [{
"id": "H7MXiMwOpRKe_WC_2oZ_S",
"date": "",
"role": "user",
"content": "第三项内容"
}],
"syncGlobalConfig": false,
"modelConfig": {
"model": "gpt-3.5-turbo-1106",
"temperature": 0.5,
"top_p": 1,
"max_tokens": 4000,
"presence_penalty": 0,
"frequency_penalty": 0,
"sendMemory": true,
"historyMessageCount": 6,
"compressMessageLengthThreshold": 1000,
"enableInjectSystemPrompts": true,
"template": "{{input}}"
},
"lang": "cn",
"builtin": false,
"createdAt": 1711334055718
}]
试一下这个,{name}就是传入的指定name的变量
$$list:$..[?(@.name =~ /{name}/i)].context[*]
谢谢,匹配到了
我尝试把content加进去:$$list:$..[?(@.name =~ /{name}/i)].context.content[*]
就不行了
谢谢,可以获得我想要的结果了。顺便问一下,你的第二张图是什么截图,看起来像是某种调试界面,我偶尔会自己创建一些动作,但是从来没用过这个界面,它是如何打开的
调试运行组合动作 - Quicker
🌹