I have stringified JSON data that contains commas in description fields. The AJAX post fails if I have apostrophes OR commas in the data.
How can I strip the following from my var test = JSON.stringify(data)
test would print out as follows:
[{"var1":"0","description":"this, has, commas"},{"var1":"1","description":"more, commas"}]
can I strip out the commas in the description so the JSON string lookes like:
[{"var1":"0","description":"this has commas"},{"var1":"1","description":"more commas"}]
and so leaving the commas that separate the objects?
or better yet...:
[{"var1":"0","description":"this \\, has \\, commas"},{"var1":"1","description":"more \\, commas"}]
Data needs to be pushed back to my server and loaded back into my DB after changes, commas and apostrophes need to remain in tact.
test.replace(/,/g,"")
of course... gets rid of the commas that separate the objects also, and screws me up.
anyone know regex well, that could suggest a way to replace a "," but "not" when between a "},{"
? (double quotes are for emphasis)
Thanks for any help.