The data does not correspond to valid JSON. Parameter name: data

  • Thread starter Thread starter Nanda
  • Start date Start date
N

Nanda

Hi - I'm facing typical browser compatibilty issue with firefox and chrome,
where as the application works fine with IE7.0 and 8.0.

I'm making a call to webservice from javascript as below but the control
never returns in success,error and timeout functions.

WebService.GetContactDetails(CurrentContactID, Onsucess, Onerror,
usercontext);

and the webmethod returns the data in JSON as below which is a valid one as
I've validated it through JSON validator. when I debugged the javascript
through firebug in firefox it throws validation error in
response.get_object() method as Sys.ArgumentException: Sys.ArgumentException:
Cannot deserialize. The data does not correspond to valid JSON. Parameter
name: data.

{
"d": {
"__type": "ContactsDB.ContactView",
"History": false,
"Deleted": false,
"Modified": "\/Date(1226910000410)\/",
"ContactVersion": 36306,
"UpdateAvailable": false,
"ContactData": {
"ADDR": [
{
"STREET": "Test",
"POBOX": null,
"POSTALCODE": "123",
"LOCALITY": "test",
"REGION": null,
"COUNTRY": "44",
"EXTRA": null,
"type": null,
"pref": null
}
],
"BIRTHDAY": null,
"EMAIL": [
{
"Email": "(e-mail address removed)",
"type": null,
"pref": null
}
],
"FORMATTED_ADDR": null,
"FORMATTED_NAME": null,
"ID": "0fa22be13c27950d4f6968",
"IDENTITY": 12345,
"NAME": {
"FAMILY": "Test",
"GIVEN": "test",
"OTHER": null,
"PREFIX": null,
"SUFFIX": null
},
"NICKNAME": null,
"NOTE": "
",
"ORG": "Test" ,
"PHOTO": null,
"PHOTO_URL": null,
"PUBLIC_KEY": null,
"PUBLIC_KEY_STRING": null,
"TEL": [
{
"Number": "+4495605470",
"type": "MOBILE",
"pref": null
},
{
"Number": "+4451858901",
"type": "WORK",
"pref": null
}
],
"TITLE": "IT direktør",
"URL": "http://www.yahoo.com"
},
"IsNew": false,
"UpdateFromSearch": true,
"ContactID": 472750,
"FirstName": null,
"LastName": null,
"Organisation": null,
"FormattedName": null,
"Email": null,
"Address": null,
"ZipCode": null,
"PreferredPhone": null,
"OtherPhone": null,
"Region": ""
}
}

I'm working with VS2008 on windows 7.
A Quick Response is very well appreciated!!

Thanks

Nanda
 
For more clarity, the exception is thrown at below function

Sys.Serialization.JavaScriptSerializer.deserialize(this.get_responseData()) .

But in strange, when i simulate the JSON data from test application by
calling just above function its not throwing any exception in firefox, but
the same input data is throwing exception (SyntaxError: unterminated string
literal) in application at below code -

try {
var exp =
data.replace(Sys.Serialization.JavaScriptSerializer._dateRegEx, "$1new
Date($2)");

if (secure && Sys.Serialization.JavaScriptSerializer._jsonRegEx.test(

exp.replace(Sys.Serialization.JavaScriptSerializer._jsonStringRegEx, '')))
throw null;
return eval('(' + exp + ')');
}
catch (e) {
throw Error.argument('data', Sys.Res.cannotDeserializeInvalidJson);
}


Any one from group would like to share their thought on this?

Thanks

Nanda


Nanda said:
Hi - I'm facing typical browser compatibilty issue with firefox and chrome,
where as the application works fine with IE7.0 and 8.0.

I'm making a call to webservice from javascript as below but the control
never returns in success,error and timeout functions.

WebService.GetContactDetails(CurrentContactID, Onsucess, Onerror,
usercontext);

and the webmethod returns the data in JSON as below which is a valid one as
I've validated it through JSON validator. when I debugged the javascript
through firebug in firefox it throws validation error in
response.get_object() method as Sys.ArgumentException: Sys.ArgumentException:
Cannot deserialize. The data does not correspond to valid JSON. Parameter
name: data.

{
"d": {
"__type": "ContactsDB.ContactView",
"History": false,
"Deleted": false,
"Modified": "\/Date(1226910000410)\/",
"ContactVersion": 36306,
"UpdateAvailable": false,
"ContactData": {
"ADDR": [
{
"STREET": "Test",
"POBOX": null,
"POSTALCODE": "123",
"LOCALITY": "test",
"REGION": null,
"COUNTRY": "44",
"EXTRA": null,
"type": null,
"pref": null
}
],
"BIRTHDAY": null,
"EMAIL": [
{
"Email": "(e-mail address removed)",
"type": null,
"pref": null
}
],
"FORMATTED_ADDR": null,
"FORMATTED_NAME": null,
"ID": "0fa22be13c27950d4f6968",
"IDENTITY": 12345,
"NAME": {
"FAMILY": "Test",
"GIVEN": "test",
"OTHER": null,
"PREFIX": null,
"SUFFIX": null
},
"NICKNAME": null,
"NOTE": "
",
"ORG": "Test" ,
"PHOTO": null,
"PHOTO_URL": null,
"PUBLIC_KEY": null,
"PUBLIC_KEY_STRING": null,
"TEL": [
{
"Number": "+4495605470",
"type": "MOBILE",
"pref": null
},
{
"Number": "+4451858901",
"type": "WORK",
"pref": null
}
],
"TITLE": "IT direktør",
"URL": "http://www.yahoo.com"
},
"IsNew": false,
"UpdateFromSearch": true,
"ContactID": 472750,
"FirstName": null,
"LastName": null,
"Organisation": null,
"FormattedName": null,
"Email": null,
"Address": null,
"ZipCode": null,
"PreferredPhone": null,
"OtherPhone": null,
"Region": ""
}
}

I'm working with VS2008 on windows 7.
A Quick Response is very well appreciated!!

Thanks

Nanda
 
Patrice - Thanks for response and that is special character and I changed it
to 'o'. still the issue remains as same.

Thanks
Nanda

Patrice said:
The "IT direktor" uses a strange character. What if you use o instead ? For
now I would say it could be just an character encoding issue...

--
Patrice


Nanda said:
For more clarity, the exception is thrown at below function

Sys.Serialization.JavaScriptSerializer.deserialize(this.get_responseData())
.

But in strange, when i simulate the JSON data from test application by
calling just above function its not throwing any exception in firefox, but
the same input data is throwing exception (SyntaxError: unterminated
string
literal) in application at below code -

try {
var exp =
data.replace(Sys.Serialization.JavaScriptSerializer._dateRegEx, "$1new
Date($2)");

if (secure &&
Sys.Serialization.JavaScriptSerializer._jsonRegEx.test(

exp.replace(Sys.Serialization.JavaScriptSerializer._jsonStringRegEx, '')))
throw null;
return eval('(' + exp + ')');
}
catch (e) {
throw Error.argument('data',
Sys.Res.cannotDeserializeInvalidJson);
}


Any one from group would like to share their thought on this?

Thanks

Nanda


Nanda said:
Hi - I'm facing typical browser compatibilty issue with firefox and
chrome,
where as the application works fine with IE7.0 and 8.0.

I'm making a call to webservice from javascript as below but the
control
never returns in success,error and timeout functions.

WebService.GetContactDetails(CurrentContactID, Onsucess, Onerror,
usercontext);

and the webmethod returns the data in JSON as below which is a valid one
as
I've validated it through JSON validator. when I debugged the javascript
through firebug in firefox it throws validation error in
response.get_object() method as Sys.ArgumentException:
Sys.ArgumentException:
Cannot deserialize. The data does not correspond to valid JSON. Parameter
name: data.

{
"d": {
"__type": "ContactsDB.ContactView",
"History": false,
"Deleted": false,
"Modified": "\/Date(1226910000410)\/",
"ContactVersion": 36306,
"UpdateAvailable": false,
"ContactData": {
"ADDR": [
{
"STREET": "Test",
"POBOX": null,
"POSTALCODE": "123",
"LOCALITY": "test",
"REGION": null,
"COUNTRY": "44",
"EXTRA": null,
"type": null,
"pref": null
}
],
"BIRTHDAY": null,
"EMAIL": [
{
"Email": "(e-mail address removed)",
"type": null,
"pref": null
}
],
"FORMATTED_ADDR": null,
"FORMATTED_NAME": null,
"ID": "0fa22be13c27950d4f6968",
"IDENTITY": 12345,
"NAME": {
"FAMILY": "Test",
"GIVEN": "test",
"OTHER": null,
"PREFIX": null,
"SUFFIX": null
},
"NICKNAME": null,
"NOTE": "?",
"ORG": "Test" ,
"PHOTO": null,
"PHOTO_URL": null,
"PUBLIC_KEY": null,
"PUBLIC_KEY_STRING": null,
"TEL": [
{
"Number": "+4495605470",
"type": "MOBILE",
"pref": null
},
{
"Number": "+4451858901",
"type": "WORK",
"pref": null
}
],
"TITLE": "IT direktør",
"URL": "http://www.yahoo.com"
},
"IsNew": false,
"UpdateFromSearch": true,
"ContactID": 472750,
"FirstName": null,
"LastName": null,
"Organisation": null,
"FormattedName": null,
"Email": null,
"Address": null,
"ZipCode": null,
"PreferredPhone": null,
"OtherPhone": null,
"Region": ""
}
}

I'm working with VS2008 on windows 7.
A Quick Response is very well appreciated!!

Thanks

Nanda
 
Back
Top