Quantcast
Channel: Yii Framework Forum
Viewing all articles
Browse latest Browse all 18717

CJSON::encode array

$
0
0
Hi,

now the CJSON::encode-function encode an associative array to a json-object.
i read the comments in the code and understand why this way was choosen.

But i think it would be better to create an array of objects with key and value as properties.

For example the following array

CJSON::encode (
array(
81523=>"87080",
81528=>"87082",
81533=>"87084",
)
);

will be encoded to this:
{"81523":"87080","81528":"87082","81533":"87084"}


I think it would be clearer (and in my opinion better to use) if it look more like this:

[
{"key":"81523", "value":"87080"},
{"key":"81528", "value":"87082"},
{"key":"81533", "value":"87084"},
]


What do you think?

Greetings from Germany
me23

Viewing all articles
Browse latest Browse all 18717

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>