Closed as not planned
Description
Description
I like the new JSON Path component.
But when I already have an object, I sometime want an easy way to access the elements. I've been using https://packagist.org/packages/adbario/php-dot-notation but there are other that provide the same functionality.
Example
$composerData = json_decode(file_get_contents('composer.json'));
$data = new Dot($composerData);
// old way, still works
foreach ($data['config']['allow-plugins'] as $plugin) {}
// with dot
foreach ($data['config.allow-plugins'] as $plugin) {}
It feels like JsonPath is pretty close to offering this. Perhaps there could be a way to implement an ArrayAccess interface so that
$jsonPath = ... (get the jsonpath object from a json string or an existing object/array).
$jsonPath['home.owner.name.first'].
Of course, at this point it's not a JsonPath, so maybe a new component could be introduce.
A bit of brainstorming here, I'm still wrapping my head around all the cool features related to DTO, and wanted to bring this up as a way to access nested values.
Metadata
Metadata
Assignees
Labels
No labels