Advertisement
abdgirk

JSON.stringify(value , replacer) different results in Chrome

Mar 22nd, 2013
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var scriptTag = document.createElement('script');
  2.         scriptTag.type = 'text/javascript';
  3.         scriptTag.src = 'https://wicked-good-xpath.googlecode.com/files/wgxpath.install.js';
  4.         document.body.appendChild(scriptTag);
  5.  
  6.  
  7. function censor(censor) {
  8.   return (function() {
  9.     var i = 0;
  10.  
  11.     return function(key, value) {
  12.  
  13. console.log(i,typeof(censor),'=====',typeof(value), value);    
  14.       if(i !== 0 && /*typeof(censor) === 'object' && typeof(value) == 'object' && */ censor == value)
  15.         return null;
  16. console.log(i,typeof(censor),'=====',typeof(value), value);
  17.       if(i >= 29) // seems to be a harded maximum of 30 serialized objects?
  18.         return null;
  19. console.log(i,typeof(censor),'=====',typeof(value), value);
  20.       ++i; // so we know we aren't using the original object anymore
  21.  
  22.       return value;  
  23.     }
  24.   })(censor);
  25. }
  26.  
  27. XPathResult = document.evaluate('**<SOME XPATH HERE>**', document, null, XPathResult.ANY_TYPE, null);
  28. var actualNode = XPathResult.iterateNext();
  29.                     var result = [];
  30.                     while (actualNode) {
  31.                         result.push(jQuery.makeArray(actualNode));
  32.                         actualNode = XPathResult.iterateNext();
  33.                     }
  34. console.log(result);                
  35. console.log("Result: ", JSON.stringify(result, censor(result)));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement