RumbleFrog

Parse Blaster File

Aug 26th, 2017
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const fs = require('fs');
  2.  
  3. const json = JSON.parse(fs.readFileSync('blast.txt'));
  4.  
  5. let count = 0;
  6.  
  7. let cvar = 'sm_cidr_version';
  8. let cvar_count = {};
  9.  
  10. Object.keys(json).forEach((key) => {
  11.     if (json[key].hasOwnProperty('rules')) {
  12.         if (json[key].rules.hasOwnProperty(cvar)) {
  13.  
  14.             let value = json[key].rules[cvar];
  15.  
  16.             if (cvar_count.hasOwnProperty(value))
  17.                 cvar_count[value]++;
  18.             else
  19.                 cvar_count[value] = 1;
  20.         }
  21.     }
  22. });
  23.  
  24. console.log(cvar_count);
Advertisement
Add Comment
Please, Sign In to add comment