Invalid characters in json response

I am unable to process the json response while accessing the json response. I am getting some invalid characters in json response, so How can we remove space issues and invalid characters from json response using php scirpt

My json response:

[{"keyword":"cosmetic dermatology","svol":4400},{"keyword":"dermatology associates","svol":22200},{"keyword"
:"advanced dermatology","svol":40500},{"keyword":"dermatology clinic","svol":3600},{"keyword":"dermatology
 specialists","svol":3600},{"keyword":"dermatology consultants","svol":5400},{"keyword":"pediatric dermatology"
,"svol":3600},{"keyword":"what is dermatology","svol":1900},{"keyword":"dermatology pictures","svol"
:1300},{"keyword":"dermatological","svol":2400},{"keyword":"laser dermatology","svol":1300},{"keyword"
:"dermatology group","svol":1900},{"keyword":"dermatology uk","svol":390},{"keyword":"dermatology courses"
,"svol":1000},{"keyword":"dermatologic","svol":1600},{"keyword":"westlake dermatology","svol":8100},
{"keyword":"pariser dermatology","svol":3600},{"keyword":"aesthetic dermatology","svol":1000},{"keyword"
:"dermatology doctors","svol":590},{"keyword":"north dallas dermatology","svol":1300} ]

      

And my JQuery:

$.ajax({
            type:"post", 
            datatype : 'json',
            url:"GetKeyWordBids.php", 
            data:"specialty="+ spevalue,
            success: function(s) {
                var object = $.parseJSON(s);
                /*oTable.fnClearTable();
                oTable.fnAddData([
                    s
                ]); */
            }
        }); 

      

FireBug output:

SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 25230 of the JSON data

      

And the Jsonlint.com output for the json response:

Parse error on line 75:
...        "keyword": "ear nose and throat
----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['

      

+3


source to share


2 answers


You don't need to use $.parseJSON();

as it is specified datatype : 'json'

. the returned data is already in JSON format, just use it directly.



+1


source


Please insert the JSON data here: http://jsonlint.com/ and see if the JSON syntax is bad.



When you fix that use Satpal's answer (don't include $ .parseJSON)

+1


source







All Articles