輸入 json :
{
"userid" : "31b25f023c58c969388991a6b9b4030000000000",
"username_id": "54fca0dd914ae593ef65988b4a3e93cccc590000000000"
}
每個值前面有 10 個 0。字串的總長度可以變化,但總是會附加 10 個 0。我想洗掉它。
因此預期的輸出:
{
"userid" : "31b25f023c58c969388991a6b9b403",
"username_id": "54fca0dd914ae593ef65988b4a3e93cccc59"
}
因此,我正在尋找使用 jolt 變換來執行這種截斷的正確方法。
uj5u.com熱心網友回復:
您可以從修改轉換開始,其中在確定屬性的十個減少長度后將子字串函式應用于屬性的每個值,以便提取除最后十個字符之外的值,因為它提到十個零總是右填充,如
[
{
"operation": "modify-overwrite-beta",
"spec": {
"userid_len": "=size(@(1,userid))",
"userid_len_dif": "=intSum(-10,@(1,userid_len))",
"userid": "=substring(@(1,&),0,@(1,userid_len_dif))",
"username_id_len": "=size(@(1,username_id))",
"username_id_len_dif": "=intSum(-10,@(1,username_id_len))",
"username_id": "=substring(@(1,&),0,@(1,username_id_len_dif))"
}
},
{
"operation": "shift",
"spec": {
"use*id": "&"
}
}
]
網站
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/452089.html
