url in json, jquery ajax response
{
"imgsrc":"http:\/\/192.168.1.181\/postcardthis\/facebook\/angel_wall.jpg",
"message":"asdf",
"friend":"Friend1",
"error_message":""
}
This my JSON
, here imgsrc
location se开发者_StackOverflow社区ems difficult, two slashes. what to do to convert perfect URL?
Use jQuery.parseJSON( json )
. It is available as of jQuery 1.4.
Description: Takes a well-formed JSON string and returns the resulting JavaScript object.
You should be able to do:
var myObj = jQuery.parseJSON('{"imgsrc":"http:\/\/192.168.1.181\/postcardthis\/facebook\/angel_wall.jpg","message":"asdf","friend":"Friend1","error_message":""}');
alert(myObj.imgsrc);
You have to eval your JSON string:
var js = eval(json_string);
Then, the imgsrc property in js will have your URL:
js.imgsrc;
精彩评论