不区分大小写的条件包含摇动变换

问题描述 投票:0回答:1

输入

{
  "type": "my Mnl"
}

type
可以包含“My mnlString”、“My Manual String”、“Credit mnl String”等值

无论大小写,当值包含(“mnl”或“Manual”)&“Credit”或(credit)(不区分大小写)时,我想将json where

type
转换为
MANUAL_CREDIT

无论大小写,当值包含(“mnl”或“Manual”)&“Debit”或“Debit”(不区分大小写)时,我想将json where

type
转换为
MANUAL_DEBIT

预期产出

{
 "type" : "MANUAL_DEBIT"
} 

{
 "type" : "MANUAL_CREDIT"
} 

默认

{
 "type" : "MANUAL_PAYMENT"
} 
json transform jolt
1个回答
0
投票

将字母的所有大小写转换为小写或大写后,您可以在移位转换规范中使用条件,以便轻松用于文字比较,例如

[
  { // convert all letters of the expression to lowercase
    "operation": "modify-overwrite-beta",
    "spec": {
      "type": "=toLower"
    }
  },
  {
    "operation": "shift",
    "spec": {
      "type": {
        "*mnl|*mnl*|mnl*|*manual|*manual*|manual*": {
          // pipes provide OR logic
          // be careful that the search string might be 
          // in the middle, start or end
          "#MANUAL_PAYMENT": "&2" // &2 copies the literal "type"
        },
        "*": {
          "#CARD_PAYMENT": "&2"
        }
      }
    }
  }
]
© www.soinside.com 2019 - 2024. All rights reserved.