I’m fresh to this whole JSON and JQuery thing, and I’m trying to read a JSON structure coming from Delphi datasnap, e.g :
{"result":[[{"type":"VOMesas.TMesas","id":1,"fields":{ "FUsers":1,"FEnclosing":0,"FClientName":"","FCode":100,"FStatus":1,"FTotalValue":128.25}}]]}
How can I read it with JQuery, more especifically the Fields:{…} content ?
EDIT :
here is the function im trying to do
function getContent(order) {
$.getJSON("query.json",
function(data) {
$.each(data.result, function(i, item) {
var grid = '<table border="1">';
for (var i=0; i < item.length; i++){
CAMPO = item[i];
...
If you’re loading the data via
jQuery.ajaxor similar and it’s being returned with the correct MIME type (or you telljQuery.ajaxthat what you’re getting back is JSON), then what you receive in thesuccesscallback will be a deserialized object (no longer JSON, but the objects that the JSON described). That being the case, you just access the properties of the object, e.g.:databeing the variable pointing to the object, which has aresultproperty that’s an array with only one entry (so, entry[0]), which is itself another array with exactly one entry (so, entry[0]again), which is an object with a property calledfields. Pictorially:If you’re retrieving the data some other way and it’s still a string, you can deserialize it using
jQuery.parseJSON:…and then do the above to access
fields.