-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Closed
Description
Symfony version(s) affected
7.3
Description
While working on symfony/ai#136 I found a behavior I'm not quite certain if intended or not.
With a JSON like this:
{
"choices": [
{
"message": {
"content": null
}
}
]
}
And a JsonPath like this: $.choices[?length(@.message.content) >= 0].message.content
I get an array with null [0 => null]
, but would just expect []
as result.
How to reproduce
To add in JsonCrawlerTest
:
public function testEmptyLengthFunction()
{
$crawler = new JsonCrawler('{"choices": [{"message": {"content": null}}]}');
$result = $crawler->find('$.choices[?length(@.message.content) >= 0].message.content');
$this->assertSame([], $result);
}
See chr-hertel#1
Possible Solution
I'm open for fixing this, but would need some serious pointers.
Additional Context
No response