null в массиве в зависимости от порядка JOLT-операции - PullRequest
0 голосов
/ 25 мая 2020

У меня такой ISON:

{
   "Customer_Id": "77777",
   "Fax": "+99 9999",
   "Phone": "+99 99998"
}

Это мой JOLT-Spe c:

[
   {
     "operation": "shift",
     "spec": {
         "Customer_Id": {
           "#OpenEditor": "initAction._type",
           "#0:1": "initAction.tableName",
           "@": "initAction.editRefID",
           "#UPDATE": "initAction.editAction"
         },
         "Phone": {
            "#SetFieldValue": "actions[#2]._type",
            "#tele": "actions[#2].fieldName",
            "@": "actions[#2].value"
         },
         "Fax": {
            "#SetFieldValue": "actions[#2]._type",
            "#fax": "actions[#2].fieldName",
            "@": "actions[#2].value"
         }
      }
   }
]

, что дает:

{
  "initAction" : {
  "_type" : "OpenEditor",
  "tableName" : "0:1",
   "editRefID" : "77777",
  "editAction" : "UPDATE"
 },
 "actions" : [ null, {
   "_type" : "SetFieldValue",
   "fieldName" : "tele",
   "value" : "+99 99998"
 }, {
   "_type" : "SetFieldValue",
   "fieldName" : "fax",
   "value" : "+99 9999"
 } ]
}

В массиве "действия" появляется null . Однако при повторном заказе JOLT-Spe c, как это

[
   {
     "operation": "shift",
     "spec": {
         "Phone": {
            "#SetFieldValue": "actions[#2]._type",
            "#tele": "actions[#2].fieldName",
            "@": "actions[#2].value"
         },
         "Fax": {
            "#SetFieldValue": "actions[#2]._type",
            "#fax": "actions[#2].fieldName",
            "@": "actions[#2].value"
         },
         "Customer_Id": {
           "#OpenEditor": "initAction._type",
           "#0:1": "initAction.tableName",
           "@": "initAction.editRefID",
           "#UPDATE": "initAction.editAction"
         }
      }
   }
]

, «ноль» исчезает:

{
 "actions" : [ {
   "_type" : "SetFieldValue",
   "fieldName" : "tele",
   "value" : "+99 99998"
 }, {
   "_type" : "SetFieldValue",
   "fieldName" : "fax",
   "value" : "+99 9999"
 } ],
  "initAction" : {
  "_type" : "OpenEditor",
  "tableName" : "0:1",
   "editRefID" : "77777",
  "editAction" : "UPDATE"
 }
}

Это правильный способ получить преобразование независимо от заказ JOLT-spe c, желательно без доп. null ?

...