Skip to content

Start reading from a specific node in the json #22

@markdza

Description

@markdza

How do you say you want to go a specific node in the json to begin parsing? For e.g. in the example json file below, I want it to only read the data array

{
  "headers": {
    "col1": "id1",
    "col1": "id2",
  },
  "data": [
    {
      "name": "John"
    },
    {
      "name": "Julie"
    }
  ]
}

If I do something like this it starts reading from the very beginning of the json and throws an error

$filename = 'abc.json';
StreamParser::json(storage_path($filename))->each(function(Collection $record){
    dd($record);
});

Can they be an implementation to do something like this (so it starts reading only data)?

$filename = 'abc.json';
StreamParser::json(storage_path($filename), 'data')->each(function(Collection $record){
    dd($record);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions