I initially receive an AJAX response of {"B":{"1":"100","3":{"AA":256}},"A":100}
and converted to a javascript object:
var jsonOBJ = {};
jsonOBJ = jQuery.parseJSON(data);
Future responses can be subsets or supersets of the initial response. If the value of a table is unchanged at the server, the stagnant data is replaced with an empty array. Example:
{"B":{"1":"90","2":200,"3":[]}}
{"B":[],"A":20}
Everytime an AJAX response is received, the object is updated with:
jQuery.extend(true, jsonOBJ, jQuery.parseJSON(data));
But I need the javascript object to keep the unchanged portions, so I need to end up with an object that would be equivalent to the following with the example responses above:
jsonOBJ = jQuery.parseJSON('{"B":{"1":"90","2":200,"3":{"AA":256}},"A":20}');
My preferred option would be to remove the empty objects from the converted response. Is there an existing function or a modification to the jQuery extend function that would do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…