开发者

json_encode url fail

Has anyone way around this bug?

echo json_encode(array('url'=>'/foo/bar'));
{"url":"\/foo\/bar"}

I use Zend_Json and Zend_Json_Expr so I can get e开发者_开发问答ven callback functions inside my js object -- but I can't get a url to come out in a usable format!

echo Zend_Json::encode(array(
                         'url'=>new Zend_Json_Expr('/foo/bar'),
                       ), false,
                       array(
                         'enableJsonExprFinder' => true),
                       ));

produces:

{"url":/foo/bar}

which obviously isn't right either..

Is there anyway to get:

{"url":"/foo/bar"}

without having to do anything ridiculous like find a way to regex it out before sending it to stdio?


{"url":"\/foo\/bar"} is actually completely valid and correct JSON for "/foo/bar". Try decoding that value using json_decode() or Zend_Json::decode() and it should output your original URL correctly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜