I first get the AJAX response {"B":{"1":"100","3":{"AA":256}},"A":100} and converted to a javascript object:
var jsonOBJ = {}; jsonOBJ = jQuery.parseJSON(data);
Future answers may be subsets or supersets of the original answer. If the table value remains unchanged on the server, stagnant data is replaced by an empty array. Example:
{"B":{"1":"90","2":200,"3":[]}}
{"B":[],"A":20}
Each time an AJAX response is received, the object is updated:
jQuery.extend(true, jsonOBJ, jQuery.parseJSON(data));
But I need a javascript object to save the unchanged parts, so I need to end up with an object that will be equivalent to the following with the above example answers:
jsonOBJ = jQuery.parseJSON('{"B":{"1":"90","2":200,"3":{"AA":256}},"A":20}');
My preferred option is to remove empty objects from the converted response. Is there an existing function or modification of the jQuery extension function that would do this?
source share