views:

33

answers:

2

{"imgsrc":"http:\/\/192.168.1.181\/postcardthis\/facebook\/angel_wall.jpg","message":"asdf","friend":"Friend1","error_message":""}

this my json, here imgsrc location seems dificult, two slahes. what to do to convert perfect url?

A: 

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);
Sagi
A: 

You have to eval your JSON string:

var js = eval(json_string);

Then, the imgsrc property in js will have your URL:

js.imgsrc;

allyourcode