Advertisement
thesuhu

Nodejs JSON

Dec 15th, 2020
1,172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Find items from json array using NodeJS
  2. // use the arrow function version of ECMAScript 2015:
  3. var result = [
  4.   {
  5.    server: 'deskes.com',
  6.     result: 'succes'
  7.   },
  8.      {
  9.     server: 'cleantarge.com',
  10.     result: 'Failed'
  11.   },
  12.      {
  13.     server: 'fance34.com',
  14.     result: 'success'
  15.   },{
  16.     server: 'deskes.com',
  17.     result: 'Failed'
  18.   }
  19. ];
  20. var rta =  result.filter(it => it.server === 'deskes.com');
  21. console.log(rta);
  22. /*
  23. Result:
  24. [
  25.   {
  26.     "server": "deskes.com",
  27.     "result": "succes"
  28.   },
  29.   {
  30.     "server": "deskes.com",
  31.     "result": "Failed"
  32.   }
  33. ]
  34. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement