震动转换问题分开记录

发布于 2025-01-31 05:38:40 字数 3270 浏览 5 评论 0原文

我正在尝试将记录的JSON转换为单个JSON记录,但很难获得值而不是名称。我希望钥匙有时会更改,并且有时会有4个以上的记录,因此我希望它具有动态性。目前的转换似乎只会给我钥匙,而不会给我自己的记录中分解的值。

输入

[
  {
    "Owner": {
      "0": "CIMections",
      "1": "CIMections",
      "2": "CIMections",
      "3": "CIMections"
    },
    "Name": {
      "0": "AFE 20NSF044",
      "1": "AFE 20NSF044",
      "2": "AFE 20NSF044",
      "3": "AFE 20NSF044"
    },
    "Producer": {
      "0": "Produtream",
      "1": "Produtream",
      "2": "Produtream",
      "3": "Produtream"
    },
    "Producers ID": {
      "0": "NTI XR 001-004",
      "1": "NTI XR 001-004",
      "2": "NTI XR 001-004",
      "3": "NTI XR 001-004"
    },
    "Weld - Real Time Count": {
      "0": "",
      "1": "",
      "2": "",
      "3": ""
    },
    "Character Set": {
      "0": "ISO_IR 192",
      "1": "ISO_IR 192",
      "2": "ISO_IR 192",
      "3": "ISO_IR 192"
    },
    "inv# Welds": {
      "0": "Accepted 001",
      "1": "Accepted 002",
      "2": "Accepted 003",
      "3": "Accepted 004"
    },
    "invoice": {
      "0": 893300361,
      "1": 411904740,
      "2": 673190473,
      "3": 1426231494
    },
    "status": {
      "0": "Done",
      "1": "Done",
      "2": "Done",
      "3": "Done"
    },
    "Date Completed": {
      "0": "20210301 163500.000000",
      "1": "20210301 163500.000000",
      "2": "20210301 163500.000000",
      "3": "20210301 163500.000000"
    },
    "Institution Name": {
      "0": "NXXT Digital",
      "1": "NXXT Digital",
      "2": "NXXT Digital",
      "3": "NXXT Digital"
    },
    "file_id": {
      "0": "00001",
      "1": "00002",
      "2": "00003",
      "3": "00004"
    }
  }
]

电流转换即时

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": {
          "Owner": "Owner.[].@(1,0)",
          "$": "&",
          "@": "@clientId"
        }
      }
    }
  }
]

通知,

{
  "Owner" : "Owner",
  "Name" : "Name",
  "Producer" : "Producer",
  "Producers ID" : "Producers ID",
  "Weld - Real Time Count" : "Weld - Real Time Count",
  "Character Set" : "Character Set",
  "inv# Welds" : "inv# Welds",
  "invoice" : "invoice",
  "status" : "status",
  "Date Completed" : "Date Completed",
  "Institution Name" : "Institution Name",
  "file_id" : "file_id"
}

但想要

{
  "Owner" : "CIMections",
  "Name" : "AFE 20NSF044",
  "Producer" : "Produtream",
  "Producers ID" : "NTI XR 001-004",
  "Weld - Real Time Count" : "",
  "Character Set" : "ISO_IR 192",
  "inv# Welds" : "Accepted 001",
  "invoice" : "893300361",
  "status" : "Done",
  "Date Completed" : "20210301 163500.000000",
  "Institution Name" : "NXXT Digital",
  "file_id" : "00001"
},
{
  "Owner" : "CIMections",
  "Name" : "AFE 20NSF044",
  "Producer" : "Produtream",
  "Producers ID" : "NTI XR 001-004",
  "Weld - Real Time Count" : "",
  "Character Set" : "ISO_I 192",
  "inv# Welds" : "Accepted 002",
  "invoice" : "411904740",
  "status" : "Done",
  "Date Completed" : "20210301 163500.000000",
  "Institution Name" : "NXXT Digital",
  "file_id" : "00002"
}...

I'm trying to transform a record json into individual json records but have a hard time getting the values rather than the names. I expect the keys to change on occasion and there to be more than 4 records on occasion so I wanted it to be dynamic. It seems the current transform will only give me the keys and not the values broken out into there own records.

Input

[
  {
    "Owner": {
      "0": "CIMections",
      "1": "CIMections",
      "2": "CIMections",
      "3": "CIMections"
    },
    "Name": {
      "0": "AFE 20NSF044",
      "1": "AFE 20NSF044",
      "2": "AFE 20NSF044",
      "3": "AFE 20NSF044"
    },
    "Producer": {
      "0": "Produtream",
      "1": "Produtream",
      "2": "Produtream",
      "3": "Produtream"
    },
    "Producers ID": {
      "0": "NTI XR 001-004",
      "1": "NTI XR 001-004",
      "2": "NTI XR 001-004",
      "3": "NTI XR 001-004"
    },
    "Weld - Real Time Count": {
      "0": "",
      "1": "",
      "2": "",
      "3": ""
    },
    "Character Set": {
      "0": "ISO_IR 192",
      "1": "ISO_IR 192",
      "2": "ISO_IR 192",
      "3": "ISO_IR 192"
    },
    "inv# Welds": {
      "0": "Accepted 001",
      "1": "Accepted 002",
      "2": "Accepted 003",
      "3": "Accepted 004"
    },
    "invoice": {
      "0": 893300361,
      "1": 411904740,
      "2": 673190473,
      "3": 1426231494
    },
    "status": {
      "0": "Done",
      "1": "Done",
      "2": "Done",
      "3": "Done"
    },
    "Date Completed": {
      "0": "20210301 163500.000000",
      "1": "20210301 163500.000000",
      "2": "20210301 163500.000000",
      "3": "20210301 163500.000000"
    },
    "Institution Name": {
      "0": "NXXT Digital",
      "1": "NXXT Digital",
      "2": "NXXT Digital",
      "3": "NXXT Digital"
    },
    "file_id": {
      "0": "00001",
      "1": "00002",
      "2": "00003",
      "3": "00004"
    }
  }
]

Current Transformation

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": {
          "Owner": "Owner.[].@(1,0)",
          "
quot;: "&",
          "@": "@clientId"
        }
      }
    }
  }
]

Im Getting

{
  "Owner" : "Owner",
  "Name" : "Name",
  "Producer" : "Producer",
  "Producers ID" : "Producers ID",
  "Weld - Real Time Count" : "Weld - Real Time Count",
  "Character Set" : "Character Set",
  "inv# Welds" : "inv# Welds",
  "invoice" : "invoice",
  "status" : "status",
  "Date Completed" : "Date Completed",
  "Institution Name" : "Institution Name",
  "file_id" : "file_id"
}

But wanting

{
  "Owner" : "CIMections",
  "Name" : "AFE 20NSF044",
  "Producer" : "Produtream",
  "Producers ID" : "NTI XR 001-004",
  "Weld - Real Time Count" : "",
  "Character Set" : "ISO_IR 192",
  "inv# Welds" : "Accepted 001",
  "invoice" : "893300361",
  "status" : "Done",
  "Date Completed" : "20210301 163500.000000",
  "Institution Name" : "NXXT Digital",
  "file_id" : "00001"
},
{
  "Owner" : "CIMections",
  "Name" : "AFE 20NSF044",
  "Producer" : "Produtream",
  "Producers ID" : "NTI XR 001-004",
  "Weld - Real Time Count" : "",
  "Character Set" : "ISO_I 192",
  "inv# Welds" : "Accepted 002",
  "invoice" : "411904740",
  "status" : "Done",
  "Date Completed" : "20210301 163500.000000",
  "Institution Name" : "NXXT Digital",
  "file_id" : "00002"
}...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮年 2025-02-07 05:38:40

$不需要通配符,但仅使用@通配符就足够了,以及用 0 1 0 | 1 ),例如

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": {
          "0|1": {
            "@": "[&].&2"
          }
        }
      }
    }
  }
]

使用 [& ]。 将每个数组转换为单个数组中的分开对象。

如果您需要将所有对象放入数组中,请用 “ 0 | 1” “*”*“*” 通配符。

$ wildcard is not needed, but only using @ wildcard is enough, along with filtering by indices with 0 and 1 (0|1) such as

[
  {
    "operation": "shift",
    "spec": {
      "*": {
        "*": {
          "0|1": {
            "@": "[&].&2"
          }
        }
      }
    }
  }
]

where prepending the value with [&]. converts each individual array to seperate objects within a single array.

If you need to get all the objects within the array, then replace "0|1" with "*" wildcard.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文