= $_POST[\'msg\'] ?>
I believe the problem is just one of escaping done by the tools you are using to output the string. For example:
var msg = dojo.toJson({field1: 'string', field2: 84, field3: 'another string'});
alert(msg);
will show the double quotes as unescaped. Similarly, running your first example while the browser is hooked up to a proxy like Charles, shows the double qoutes as unescaped.
So I believe this is just an auto-escape that Firebug/PHP does when showing you strings.