I'm encoding a very basic array like this.
$c['A']=NULL;
$c=json_encode($c);
I later want to decode the json and add a new key
$c=json_decode($c);
$c[B]=NULL;
The problem is that $c is now an object.
json_decode() is returning PHP Object. You need 2nd parameter if you want it to be array:
$c=json_decode($c, true);
look:http://php.net/manual/en/function.json-decode.php
When TRUE, returned objects will be converted into associative arrays.