I need to turn a string like this:
' query: "help me" distance: "25" count: "50" '
into a javascript object or json string that looks like this:
'{ query: "help me", distance: "25", count: "50" }'
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Something like this, perhaps:
With that lookahead expression I just put comma after all the double quotation marks that are followed by whitespace symbol.
Having said that, I’d strongly suggest reconsidering the method of constructing your params: somehow I feel you could get away with simple
JSON.stringify-ing the params. It will be much more bulletproof – and easier to parse too.