Skip to content

Can I obtain a certain field in the parent field? #12

@tlsproxy

Description

@tlsproxy

Wow, thank you for making it open source. This is really a useful library of tools. I have encountered a problem and would like you to help me with it:

The following is my original JSON structure:

[
  {
    "date": "2025-01-16-16-20-38-126",
    "location": [
      {
        "x": 2.7391487568478716,
        "y": 4.424778761061947
      },
      {
        "x": 88.20058997050147,
        "y": 4.298356510745891
      }
    ]
  },
  {
    "date": "2025-01-16-16-20-16-469",
    "location": [
      {
        "x": 2.7391487568478716,
        "y": 4.424778761061947
      },
      {
        "x": 88.20058997050147,
        "y": 4.298356510745891
      },
      {
        "x": 28.487147071217866,
        "y": 4.804045512010114
      }
    ]
  }
]

I want to convert it into the following format:

[
  {
    "date": "2025-01-16-16-20-38-126",
    "x": 2.7391487568478716,
    "y": 4.424778761061947
  },
  {
    "date": "2025-01-16-16-20-38-126",
    "x": 88.20058997050147,
    "y": 4.298356510745891
  },
  {
    "date": "2025-01-16-16-20-16-469",
    "x": 2.7391487568478716,
    "y": 4.424778761061947
  },
  {
    "date": "2025-01-16-16-20-16-469",
    "x": 88.20058997050147,
    "y": 4.298356510745891
  },
  {
    "date": "2025-01-16-16-20-16-469",
    "x": 28.487147071217866,
    "y": 4.804045512010114
  }
]

At present, I can expand the original data structure as follows:

[
  {
    "x": 2.7391487568478716,
    "y": 4.424778761061947
  },
  {
    "x": 88.20058997050147,
    "y": 4.298356510745891
  },
  ....
]

But I have no way to include the "date" field in the "location" field. What should I do? Is there something like parent that allows me to obtain the "location" field at the upper level within the location field?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions