I am working with “jQuery Data Link Plugin”.And it is collecting information from textbox and returning object.
I am trying to convert the object to string using “JSON.stringify(obj)”.
using following function:
function formatObject(obj){
return JSON.stringify(obj).replace(/,/g,'test').replace('{','{\n ').replace('}','\n}')
}
It returns the object value in this format:
{
"name":"name"test"country":"country"test"age":"22"
}
I have to turn this object into this like an url,(example:”http://test.com/search?name=name&&country=test&&age=22″)
How to convert that josn object into string url?
I have tried with several answer found by googling,unfortunately can not get as expected.
Thanks.
I think this the way to do it:
Play with it here:
http://jsfiddle.net/tzdqr/
I guess you want
replace(/,/g,'&')but I’m not sure why.