This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
Associative array is not encoded into an object using json_encode
.
#26
Comments
The default behavior is to return an array instead of an object unless you force it. That was the default case on 2012 unless the PHP group changed it later.
…-----Original Message-----
From: MDTech-us-MAN <[email protected]>
To: symisc/PH7 <[email protected]>
Cc: Subscribed <[email protected]>
Sent: Sat, 18 Aug 2018 22:14
Subject: [symisc/PH7] Associative array is not encoded into an object using `json_encode`. (#26)
Hello,
I found that if an associative array returned from a foreign function and passed into `json_encode`, it returns an array instead of an object unless I add [`JSON_FORCE_OBJECT`](http://php.net/manual/en/json.constants.php#constant.json-hex-quot). This is not the correct behaviour.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#26
|
This is a link to a php tutorial for this kind of thing: https://www.dyn-web.com/tutorials/php-js/json/array.php#assoc See this online php sandbox: http://sandbox.onlinephpfunctions.com/code/1d75b0a84813ebb107646563f5935d4aa524f37d The result is the same as far back as version 5.2.16 (released 16 December 2010), which seems to be the first version that has |
Here is a sample that shows what |
Maxwell175
added a commit
to Maxwell175/SSNFS
that referenced
this issue
Aug 24, 2018
This will be used in the coming feature. Upstream issue: symisc/PH7#26
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hello,
I found that if an associative array is returned from a foreign function and passed into
json_encode
, it returns an array instead of an object unless I addJSON_FORCE_OBJECT
. This is not the correct behaviour. Associative arrays are supposed to encode into json objects.The text was updated successfully, but these errors were encountered: