I have json data represented like this
{key:\"value\"}
(no quotes arround key...)
I want to translate it to an associative array.>
If you can't turn that into valid JSON at the source, then you can use Services_JSON from PEAR to parse it, since adding quotes around the key is a non-trivial error-prone process.
Services_JSON
will correctly parse the invalid key string.
Example:
$json = new Services_JSON();
var_dump($json->decode('{key:"value"}'));
Output:
object(stdClass)#2 (1) {
["key"]=>
string(5) "value"
}