There appears to be an oddity with json_encode and/or json_decode when attempting decode a string that was produced by json_encode:
$object = new stdClas
You can just use the stripslashes function to strip the dashes and it will work tested
$yetAnotherObject = json_decode(stripslashes('{"namespace":"myCompany\\package\\subpackage"}'));