Re: ArrayPath

From: Date: Wed, 08 Oct 2014 01:21:48 +0000
Subject: Re: ArrayPath
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-77825@lists.php.net to get a copy of this message
> This request seems to be more in the realm of having XPath type support for > arrays, likewise people have also attempted to do this with JSON. It does > seem like it could be valuable to some degree, however, I don't necessarily > believe it belongs in the core. This seems much better for a PECL module > if necessary. > > If the key has a / it would seem like you should escape it like a regular > string escape, aka "\/". I'm not convinced this is something that is > necessary in PHP either. There does not seem to be a great use case for > this use. I agree that this definitely does not belong in core. This has been tried with json via json-path, but there's no formal grammar or compliance test suite to back it. It's basically a really old blog post that has never been formalized. There's a much more robust alternative called jmespath that works across multiple languages and has a PHP implementation: https://github.com/mtdowling/jmespath.php I think this shows that this is a problem that can and has already been solved in user land (multiple times in multiple ways), and it can be done in a performant way (e.g., compiling expressions into PHP code). I don't see a need to add bloat to PHP's core for this. -Michael

« previous php.internals (#77825) next »