为什么带有不存在的键的更新运算符会产生两个单独的键/值?

时间:2020-10-29 11:35:34

标签: dataweave mulesoft

我正在尝试使用更新运算符

  case long at .reservations.*reservation.*flight.destination.longitude -> 
 long as Number as String {format: "###.000"} 
  case lat at .reservations.*reservation.*flight.*destination.latitude -> 
 lat as Number as String {format: "###.000"} 
   case congestion at .reservations.*reservation.flight.*destination.*status! 
    -> 
 "Moderate Traffic"
  //case dest at .reservations.*reservation.*flight.*destination -> dest
}

每个预订对象只有一个航班,只有一个目的地孩子。状态密钥不存在。更新运算符的结果是添加了两个单独的状态键/值,一个在原始目标对象中,然后在与原始子节点相同的级别上添加了一个新的空目标对象。

"reservations":{ 
  "reservation": {
    "First Name" : "Andrea",
...
    "flight": {
      "destination": { 
   
        "timeZone": "America/Los_Angeles",
        "status": "Moderate Traffic"
       }
      },
      "flight": {
        "destination": {
          "status": "Moderate Traffic"
        }
      }
    },
    "reservation": {
      "First Name": "Andrea",
      "Last Name": "Schmidt",
...

如何调整选择器或添加什么条件表达式以仅在原始匹配的目标对象内添加缺少的状态键/值?

0 个答案:

没有答案