Bug #65955 [Opn->Csd]: Invalid Json response
| From: | aaatoja at o2 dot pl | Date: | Thu, 24 Oct 2013 10:26:29 +0000 |
| Subject: | Bug #65955 [Opn->Csd]: Invalid Json response | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-182446@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65955&edit=1
ID: 65955
User updated by: aaatoja at o2 dot pl
Reported by: aaatoja at o2 dot pl
Summary: Invalid Json response
-Status: Open
+Status: Closed
Type: Bug
Package: PDO related
Operating System: Linux Ubuntu
PHP Version: 5.4.21
Block user comment: N
Private report: N
New Comment:
I see bug is fixed in v5.5.
Previous Comments:
------------------------------------------------------------------------
[2013-10-24 07:31:37] aaatoja at o2 dot pl
Description:
------------
I have a Postgresql (v9.3) view which contains column made from json_agg() function (array_agg works
fine).
My response looks like:
array(5) {
[0] => array(2) {
["aggcolumn"] => NULL
[0] => NULL
}
[1] => array(2) {
["aggcolumn"] => string(14) "["test"]]"
[0] => string(14) "["test"]]"
}
[2] => array(2) {
["aggcolumn"] => string(34) "["test", "test2"]]]"
[0] => string(34) "["test", "test2"]]]"
}
[3] => array(2) {
["aggcolumn"] => string(26) "["test3"]]]]"
[0] => string(26) "["test3"]]]]"
}
[4] => array(2) {
["aggcolumn"] => string(46) "["test2", "test3"]]]]]"
[0] => string(46) "["test2", "test3"]]]]]"
}
}
Test script:
---------------
try {
$dbh = new PDO($dsn, $user, $password);
$sth = $dbh->prepare('SELECT aggcolumn FROM view_test WHERE company_id = ? AND
active_flag IS TRUE');
$sth->execute(array(10));
$res = $sth->fetchAll();
var_dump($res);
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
Expected result:
----------------
Response should be valid JSON string.
Actual result:
--------------
As You may notice every row has a value with an extra ']' at the end, based on current
iteration count. That makes string invalid JSON response
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65955&edit=1