0

I have a SignalR client application that receives a Json serialized list of objects. When I run the following script on the incoming data:

connection.received(function (data) {
  $.each(divIds, function (index, id) {
      $.each(data, function (index2, object) {
          updateCell(object.property1);
          updateCell(object.property2);
      });
  });
});

alert() tells me that $.each iterates over each character in the incoming data as a string, instead of the data being treated as a list of objects.

The incoming data is:

[{"property1":"value1","property2":41.3},{"property1":"value2","property2":43.2},{"property1":"value3","property2":559.1}]

The data is created on the server with this:

string output = JsonConvert.SerializeObject(list, Formatting.None).Trim();

What am I doing wrong?

stombeur
  • 2,704
  • 22
  • 45
  • see [http://stackoverflow.com/questions/2342371/jquery-loop-on-json-data-using-each][1] [1]: http://stackoverflow.com/questions/2342371/jquery-loop-on-json-data-using-each – stombeur Dec 19 '11 at 22:37

1 Answers1

0

solved this with the method explained in jquery loop on Json data using $.each

data = eval(data.replace(/[\r\n]/, ""));

Community
  • 1
  • 1
stombeur
  • 2,704
  • 22
  • 45