Check-in [6c8e7d4e1f]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix json_encode to always output object keys as strings. |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
6c8e7d4e1fa374cad03ac79c7506b534 |
User & Date: | mario 2014-04-27 17:08:31 |
Context
2014-08-14
| ||
07:22 | Variant of var_export that utilizes php 5.4 array [] syntax. check-in: a33d1695b1 user: mario tags: trunk | |
2014-04-27
| ||
17:08 | Fix json_encode to always output object keys as strings. check-in: 6c8e7d4e1f user: mario tags: trunk | |
2014-04-24
| ||
02:51 | Remove more preg_replace /e with static callbacks check-in: c46171bf99 user: mario tags: trunk | |
Changes
Changes to upgrade.php.
︙ | ︙ | |||
869 870 871 872 873 874 875 | $obj = !($keys == array_keys($keys)); // keys must be in 0,1,2,3, ordering, but PHP treats integers==strings otherwise } #-- concat individual entries $empty = 0; $json = ""; foreach ((array)$var as $i=>$v) { $json .= ($empty++ ? ",$_nl" : "") // comma separators | | | 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 | $obj = !($keys == array_keys($keys)); // keys must be in 0,1,2,3, ordering, but PHP treats integers==strings otherwise } #-- concat individual entries $empty = 0; $json = ""; foreach ((array)$var as $i=>$v) { $json .= ($empty++ ? ",$_nl" : "") // comma separators . $_tab . ($obj ? (json_encode((string)$i, $options & ~JSON_NUMERIC_CHECK, $_tab) . ":$_space") : "") // assoc prefix . (json_encode($v, $options, $_tab)); // value } #-- enclose into braces or brackets $json = $obj ? "{"."$_nl$json$_nl$_indent}" : "[$_nl$json$_nl$_indent]"; } |
︙ | ︙ |