Bhoomi
Bhoomi

Reputation: 801

JQuery ParseJson - bad control character literal error

I know this is a silly problem. I am getting error in this code :

jQuery.parseJSON('{"Particulars":"CHEQUE NO. 010567 DATED 19/4/2013 BRANCH  FROM INSTRUMENTS P LTD_C08015186 AGST MHX217    9554    17/04/2013  30633"}');

Error is : SyntaxError: JSON.parse: bad control character in string literal

It seems there is a line feed in the string. Since it is invisible I cannot replace it. JSONLint also throws error.

How to get around with this invisible control character?

Upvotes: 1

Views: 2872

Answers (1)

Bhoomi
Bhoomi

Reputation: 801

Oh yes techfoobar you are right.

Invisible character is Tab.

This did it :

.replace(/\s+/g,"")

Thanks...

Upvotes: 3

Related Questions