views:

270

answers:

1

I'm upgrading an application that was using jQuery 1.3.2 to consume a WCF Data Service (a.k.a. ADO.NET Data Services, a.k.a. Astoria) to use the latest version of jQuery (1.4.2). My application is now failing, with JSON parsing errors, because jQuery 1.4 now uses stricter JSON parsing.

I've run the JSON returned by my data service through various JSON validators, and the problem seems to be related to single-quote escaping in URI strings. My JSON looks like the following:

{
    "d" : {
        "__metadata": {
            "uri": "http://foo.com/Services/Foo.svc/Foos(guid\'g17a49d5-fd66-4b2d-bd5f-e6245ec3e268\')" } } }

(I've modified it to remove unnecessary information.)

The parsing error is with the '\' escaping of single-quotes. If I remove the escape character, the JSON parses cleanly.

Has anyone had this problem, and have a fix or a work-around?

Thanks.

+1  A: 

This is a bug in data services in .NET 3.5 SP1 & subsequent update. The issue will be fixed in the in .NET 4.0 release.

Mike Flasko
Thanks for the response, Mike. I've worked around the issue for the time being by having my code revert to the eval-based JSON parsing method that jQuery used prior to 1.4. I'll look forward to undoing that change once we move the app to .NET 4.0.
Gabriel Boyer