The json_decode function expects strictly formed JSON and won’t accept values without a key however, the way in which I intend to use it the keys don’t matter and repeatedly, manually specifying numerical keys is tedious.
The most obvious answer would be to write my own ‘JSON’ decoder that would intuitively assign numerical keys if they are omitted from the string being decoded. I’m trying to determine if there is a more obvious solution that I am not seeing.
To be more specific, I want to be able to decode a string like:
{"my", "array", "of", "values"}
as if it was written like this
{"0":"my", "1":"array", "2":"of", "3":"values"}
The values of the index are moot. I’ll be using a foreach and the order doesn’t matter, its just extra typing to form my source JSON that way, hence the search for a shortcut.
You could use the json array structure like this:
[1,2,3,4,5]