This seems like a no brainer but surely there is either an internal js method or a jquery one to take a string like:
intTime=1324443870&fltOriginalAmount=0.00&strOriginalCurrency=GBP
...then a lot more vals and turn it into a JSON object?
I had a dig around this site and google and surprisingly drew blanks... Anyone got an easy way to do this?
jQuery BBQ does exactly this. See $.deparam
, "The opposite of jQuery.param, pretty much."
> var obj = $.deparam('intTime=1324443870&fltOriginalAmount=0.00&strOriginalCurrency=GBP')
> JSON.stringify(obj)
'{"intTime":"1324443870","fltOriginalAmount":"0.00","strOriginalCurrency":"GBP"}'
i used this hack...
$.parseJSON('{"' + qs.replace(/&/g, '","').replace(/=/g, '":"') + '"}');
demo here http://jsbin.com/niqaw/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With