Hi,
The JsonObject class turns empty objects into empty arrays and thus is unable to give back the original JSON representation.
For example:
{
"item1": {},
"item2": {}
}
Is returned as:
{
"item1": [],
"item2": []
}
Here is how to reproduce it:
public function test() {
$this->assertEquals('[{"item":"value"}]', (new JsonObject('[{"item":"value"}]'))->getJson());
$this->assertEquals('{"item":"value"}', (new JsonObject('{"item":"value"}'))->getJson());
$this->assertEquals('[]', (new JsonObject('[]'))->getJson());
$this->assertEquals('{}', (new JsonObject('{}'))->getJson()); // FAILS!
}
Failed asserting that two strings are equal.
Expected :'{}'
Actual :'[]'
Best regards,
Hi,
The
JsonObjectclass turns empty objects into empty arrays and thus is unable to give back the original JSON representation.For example:
{ "item1": {}, "item2": {} }Is returned as:
{ "item1": [], "item2": [] }Here is how to reproduce it:
Best regards,