1

I have JSON objects coming back from ASP.Net oData services which I am reading through JayData oData provider. On one service, JSON object is read into an array without any problems. On another service (from same server), the resulting array contains only etag data for all the elements.

I am not sure if there is a format mismatch or JayData is not decoding the JSON format correctly.

Could someone take a look and see where the problem is located?

Here is the header

GET /GCSData.svc/Customers HTTP/1.1
Referer: http://localhost:56786/HTMLClient/
MaxDataServiceVersion: 2.0
DataServiceVersion: 2.0
Accept: application/atomsvc+xml;q=0.8, application/json;odata=verbose;q=0.5, */*;q=0.1
Accept-Language: en-US
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko
Connection: Keep-Alive
DNT: 1
Host: localhost:56786


HTTP/1.1 200 OK
Cache-Control: no-cache
Content-Length: 2051
Content-Type: application/json;odata=verbose;charset=utf-8
Server: Microsoft-IIS/8.0
X-Content-Type-Options: nosniff
DataServiceVersion: 1.0;
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcQ2hpIFJvd1xkb2N1bWVudHNcdmlzdWFsIHN0dWRpbyAyMDEzXFByb2plY3RzXEdDU2xzXEdDU2xzXGJpblxEZWJ1Z1xHQ1NEYXRhLnN2Y1xDdXN0b21lcnM=?=
X-Powered-By: ASP.NET
Date: Mon, 31 Mar 2014 19:35:09 GMT

and here is the JSON data.

{"d":[{"__metadata":{"id":"http://localhost:56786/GCSData.svc/Customers(1)","uri":"http://localhost:56786/GCSData.svc/Customers(1)","etag":"W/\"'John%20%20%20%20%20%20','Doe%20%20%20%20%20%20%20','1234567890'\"","type":"LightSwitchApplication.Customer"},"Orders":{"__deferred":{"uri":"http://localhost:56786/GCSData.svc/Customers(1)/Orders"}},"CustID":1,"FName":"John      ","LName":"Doe       ","Phone":"1234567890"},{"__metadata":{"id":"http://localhost:56786/GCSData.svc/Customers(2)","uri":"http://localhost:56786/GCSData.svc/Customers(2)","etag":"W/\"'Jane%20%20%20%20%20%20','Smith%20%20%20%20%20','7703211234'\"","type":"LightSwitchApplication.Customer"},"Orders":{"__deferred":{"uri":"http://localhost:56786/GCSData.svc/Customers(2)/Orders"}},"CustID":2,"FName":"Jane      ","LName":"Smith     ","Phone":"7703211234"},{"__metadata":{"id":"http://localhost:56786/GCSData.svc/Customers(3)","uri":"http://localhost:56786/GCSData.svc/Customers(3)","etag":"W/\"'Dan%20%20%20%20%20%20%20','Handy%20%20%20%20%20','6789876543'\"","type":"LightSwitchApplication.Customer"},"Orders":{"__deferred":{"uri":"http://localhost:56786/GCSData.svc/Customers(3)/Orders"}},"CustID":3,"FName":"Dan       ","LName":"Handy     ","Phone":"6789876543"},{"__metadata":{"id":"http://localhost:56786/GCSData.svc/Customers(4)","uri":"http://localhost:56786/GCSData.svc/Customers(4)","etag":"W/\"'Mike%20%20%20%20%20%20','Smith%20%20%20%20%20','4041231234'\"","type":"LightSwitchApplication.Customer"},"Orders":{"__deferred":{"uri":"http://localhost:56786/GCSData.svc/Customers(4)/Orders"}},"CustID":4,"FName":"Mike      ","LName":"Smith     ","Phone":"4041231234"},{"__metadata":{"id":"http://localhost:56786/GCSData.svc/Customers(5)","uri":"http://localhost:56786/GCSData.svc/Customers(5)","etag":"W/\"'Aaron%20%20%20%20%20','Hayes%20%20%20%20%20','2431235678'\"","type":"LightSwitchApplication.Customer"},"Orders":{"__deferred":{"uri":"http://localhost:56786/GCSData.svc/Customers(5)/Orders"}},"CustID":5,"FName":"Aaron     ","LName":"Hayes     ","Phone":"2431235678"}]}

In the resulting array, for each Customer, all the fields (FName, LName, phone) contain the exact data (which equals to the "etag" field). Here is an example for Customer(1)

{"CustID":1,"FName":"W/\"'John%20%20%20%20%20%20','Doe%20%20%20%20%20%20%20','1234567890'\"","LName":"W/\"'John%20%20%20%20%20%20','Doe%20%20%20%20%20%20%20','1234567890'\"","Phone":"W/\"'John%20%20%20%20%20%20','Doe%20%20%20%20%20%20%20','1234567890'\""}

The JSON data is read through toLiveArray() method.

Chi Row
  • 1,106
  • 7
  • 18

1 Answers1

1

Make sure you use the [TimeStamp] attribute on server-side to publish your ETag in byte array format:

[Timestamp]
public byte[] token { get; set; }
Robesz
  • 1,646
  • 11
  • 13
  • To those that need more help with this. You actually add the code that Robesz has in his post to your Entity in your WCF RIA method. It will then fix the error and it will work. – Michael Washington Dec 09 '15 at 02:29