It's easier if you use $json[$id] = $name