In this post, I learned how to encode an object on the server side, and now I would like to decode it on the client side.
On the client side, I do
$.ajax({ type: "GET", url: "/cgi-bin/ajax_sort.pl", contentType: "application/json; charset=utf-8", dataType: "json", data: { "column" : this.id }, error: function(XMLHttpRequest, textStatus, errorThrown) { showError('responseText: ' + XMLHttpRequest.responseText); showError('textStatus: ' + textStatus); showError('errorThrown: ' + errorThrown); }, success: function(result){ if (result.error) { showError(result.error); } else { var obj = jQuery.parseJSON(result); } } });
Question
Does obj now have decoded JSON data?
If so, the object looks like it is on the server side (output from Perl Data::Dumper )
$VAR1 = { '127' => { 'owners' => [ 'm' ], 'users' => [ 'hh', 'do' ], 'date_end' => '24/05-2011', 'title' => 'dfg', 'date_begin' => '24/05-2011', 'members_groups' => [], 'type' => 'individuel' }, '276' => { ...
Question
Is obj really contains decoded JSON, how can I iterate over an object?
source share