带有嵌套 JSON 的 Bootstrap 表

发布于 2025-01-15 07:41:07 字数 1814 浏览 1 评论 0原文

我正在尝试引用 JSON 文件中的值以显示在引导表中。 JSON 文件的选择如下:

    {
  "summary": [
      "2022-03-03 02:52:39 UTC P @ OD06 -  2022-03-03 04:00:08 UTC 01+07 LOW SJ  SJ-DG-QM-CB-CL-HT-HV-HZ",
      "2022-03-03 03:29:29 UTC E @ OD19 -  2022-03-03 15:01:25 UTC 11+31 HIGH ZV  ZV-TA-MI-FC-FY-AL-TU-BR-KN-WH-VT",
      "2022-03-03 03:46:59 UTC F @ OD18 -  2022-03-03 15:22:16 UTC 11+35 HIGH GO  GO-FR-BO-NA-HI-GR-CH-VN-QY-FO-GY-SA-NS-JE"
  ],
  "detail": [
      {
          "_id": {
              "$oid": "62330bd6eefd332ac0855c52"
          },
          "duration": 4049,
          "edate": "2022-03-03T04:00:08.000Z",
          "expires_at": "2024-11-27T02:52:39.000Z",
          "flightinfo": {
              "numberofac": 9,
              "flightmins": 160,
              "pace": 4,
              "interval": 300,
              "sdate": "2022-03-03T02:52:39.000Z",
              "edate": "2022-03-03T04:00:08.000Z"
          },
          "json_class": "SectorOpen",
          "lastsrtreport": "20220303040008.0000045306",
          "master": "SJ",
          "od": "06",
          "sdate": "2022-03-03T02:52:39.000Z",
          "slaves": [
              "DG",
              "CL",
              "QM",
              "CB",
              "HT",
              "HZ",
              "HV"
          ]
      }
    ]
  }

我试图在引导表中显示“主”键的值。

该值的路径是 $.detail[*].master ,当我使用 JSONPath.com 验证它时,它按预期返回“SJ”的值。

但是,我无法获取要在表中显示的值。

这是该表的 html:

<table id="table" data-toggle="table" data-url="data.json">
            <thead>
              <tr>

                <th data-field="$.detail[*].master">Master</th>
               
              </tr>
            </thead>
          </table> 

我做错了什么?这是返回 JSON 的格式吗?

谢谢你!

I am trying to reference a value in my JSON file to display in a bootstrap table. A selection of the JSON file is as follows:

    {
  "summary": [
      "2022-03-03 02:52:39 UTC P @ OD06 -  2022-03-03 04:00:08 UTC 01+07 LOW SJ  SJ-DG-QM-CB-CL-HT-HV-HZ",
      "2022-03-03 03:29:29 UTC E @ OD19 -  2022-03-03 15:01:25 UTC 11+31 HIGH ZV  ZV-TA-MI-FC-FY-AL-TU-BR-KN-WH-VT",
      "2022-03-03 03:46:59 UTC F @ OD18 -  2022-03-03 15:22:16 UTC 11+35 HIGH GO  GO-FR-BO-NA-HI-GR-CH-VN-QY-FO-GY-SA-NS-JE"
  ],
  "detail": [
      {
          "_id": {
              "$oid": "62330bd6eefd332ac0855c52"
          },
          "duration": 4049,
          "edate": "2022-03-03T04:00:08.000Z",
          "expires_at": "2024-11-27T02:52:39.000Z",
          "flightinfo": {
              "numberofac": 9,
              "flightmins": 160,
              "pace": 4,
              "interval": 300,
              "sdate": "2022-03-03T02:52:39.000Z",
              "edate": "2022-03-03T04:00:08.000Z"
          },
          "json_class": "SectorOpen",
          "lastsrtreport": "20220303040008.0000045306",
          "master": "SJ",
          "od": "06",
          "sdate": "2022-03-03T02:52:39.000Z",
          "slaves": [
              "DG",
              "CL",
              "QM",
              "CB",
              "HT",
              "HZ",
              "HV"
          ]
      }
    ]
  }

I am trying to display the value of the "master" key in a bootstrap table.

The path to the value is $.detail[*].master and returns the value of "SJ" as expected when I use JSONPath.com to validate it.

However, I can't get the value to display in the table.

This is the html for the table:

<table id="table" data-toggle="table" data-url="data.json">
            <thead>
              <tr>

                <th data-field="$.detail[*].master">Master</th>
               
              </tr>
            </thead>
          </table> 

What am I doing wrong? Is it the format that the JSON is being returned?

Thank you!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文