英文:
How to remove single quotes from string in Jolt Spec
问题
以下是已翻译好的部分:
输入:
{
"text": "2023-05-24 12:11:06.185 google.com i-axcel: phone 'New Launch of software city' on USKANSAS changed from USNYC"
}
Jolt 规范:
[
{
"operation": "shift",
"spec": {
"text": ["description_cpy2"]
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"description_cpy2": "=split('phone', @(1, description_cpy2))",
"pharse": "=split('changed', @(1, description_cpy2[1]))",
"pharseone": "@(1, pharse[0])",
"pharsetwo": "@(1, pharse[0])"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"pharseone": "=trim",
"pharsetwo": "=trim"
}
},
{
"operation": "shift",
"spec": {
"pharseone": "pharseone",
"pharsetwo": "pharsetwo"
}
}
]
当前输出:
{
"pharseone" : "'New Launch of software city' on USKANSAS",
"pharsetwo" : "'New Launch of software city' on USKANSAS"
}
期望输出:
{
"pharseone" : "New Launch of software city on USKANSAS",
"pharsetwo" : "New Launch of software city on USKANSAS"
}
如果您需要更多帮助,请随时告诉我。
英文:
I am phrasing the value of a long string where the data comes with single quotes ('). how we can remove the single quotes in Jolt Specification. Please suggest.
Input :
{
"text": "2023-05-24 12:11:06.185 google.com i-axcel: phone 'New Launch of software city' on USKANSAS changed from USNYC"
}
Jolt Spec :
[
{
"operation": "shift",
"spec": {
"text": ["description_cpy2"]
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"description_cpy2": "=split('phone',@(1,description_cpy2))",
"pharse": "=split('changed',@(1,description_cpy2[1]))",
"pharseone": "@(1,pharse[0])",
"pharsetwo": "@(1,pharse[0])"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"pharseone": "=trim",
"pharsetwo": "=trim"
}
},
{
"operation": "shift",
"spec": {
"pharseone": "pharseone",
"pharsetwo": "pharsetwo"
}
}
]
Current Output :
{
"pharseone" : "'New Launch of software city' on USKANSAS",
"pharsetwo" : "'New Launch of software city' on USKANSAS"
}
Expected output :
{
"pharseone" : "New Launch of software city on USKANSAS",
"pharsetwo" : "New Launch of software city on USKANSAS"
}
答案1
得分: 3
它在Jolt中没有直接的函数方式,但你可以使用shift
操作来单独获取'
并将其删除。
[
{
"operation": "shift",
"spec": {
"text": ["description_cpy2"]
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"description_cpy2": "=split('phone', @(1, description_cpy2))",
"pharse": "=split('changed', @(1, description_cpy2[1]))",
"pharseone": "@(1, pharse[0])",
"pharsetwo": "@(1, pharse[0])"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"pharseone": "=trim",
"pharsetwo": "=trim",
"pharseon*": "=split('', @(1, pharseone))",
"pharsetw*": "=split('', @(1, pharsetwo))"
}
},
{
"operation": "shift",
"spec": {
"pharse*": {
"*": {
"'": {
"@1": "temp_&3"
},
"*": {
"@1": "&3"
}
}
}
}
},
{
"operation": "remove",
"spec": {
"temp_*": ""
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"*": "=join('', @(1, &))"
}
}
]
英文:
It doesn't have a straight way with functions in Jolt, But you can use the shift
operation to get '
separately and remove them.
[
{
"operation": "shift",
"spec": {
"text": ["description_cpy2"]
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"description_cpy2": "=split('phone',@(1,description_cpy2))",
"pharse": "=split('changed',@(1,description_cpy2[1]))",
"pharseone": "@(1,pharse[0])",
"pharsetwo": "@(1,pharse[0])"
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"pharseone": "=trim",
"pharsetwo": "=trim",
"pharseon*": "=split('',@(1,pharseone))",
"pharsetw*": "=split('',@(1,pharsetwo))"
}
},
{
"operation": "shift",
"spec": {
"pharse*": {
"*": {
"'": {
"@1": "temp_&3"
},
"*": {
"@1": "&3"
}
}
}
}
},
{
"operation": "remove",
"spec": {
"temp_*": ""
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"*": "=join('',@(1,&))"
}
}
]
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论