我需要使用 JOLT 从该 JSON 中的“name”:“username”值中提取电子邮件地址:
我以为会这样
customer:{
"*":{
"name"{
"username":"email.@(2,value)
}
}
}
输入
{
"customer": [
{
"name": "title",
"value": "Mr"
},
{
"name": "address",
"value": "park road"
},
{
"name": "username",
"value": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fa9995948e9b998e8f89ba9f979b9396d4999597" rel="noreferrer noopener nofollow">[email protected]</a>"
}
]
}
预期输出
{
"email":"<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f2919d9c869391868781b2979f939b9edc919d9f" rel="noreferrer noopener nofollow">[email protected]</a>
}
最佳答案
我认为你需要一个包含这样的条件的规范
[
{
"operation": "shift",
"spec": {
"*": { // represents the array
"*": { // represents the indexes of the array
"name": {
// in order to pick the desired condition
"username": {
// go 2 levels up and grab the value of "value" key
// as roaming within each objects of the main array(customer)
// [eg. reaching the level of the indexes of the array]
"@(2,value)": "email" //rename the key as desired
}
}
}
}
}
}
]
关于arrays - 使用 JSON 数组中另一个值的匹配来提取特定值到 JOLT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69381532/