2

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 even 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?

1 Answer 1

7

{"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.

Sign up to request clarification or add additional context in comments.

2 Comments

yes, it is correct JSON, and upon further investigation window.location = 'http:\/\/www.google.com\/'; seems to work.. looks like it's as bug in the plugin i'm using :-p
And, using _Expr essentially just tells the encoder to not put it in quotes or escape the value - much like Zend_Db_Expr.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.