Advertisement
Guest User

JSON data and expecting output

a guest
Aug 29th, 2014
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // JSON source data
  2. [
  3.     {
  4.         "dates": [
  5.             {
  6.                 "datetime": "2014-08-26",
  7.                 "deviceModels": [
  8.                     {
  9.                         "deviceModel": "Canon450MX",
  10.                         "devices": [
  11.                             {
  12.                                 "deviceModel": "Canon450MX",
  13.                                 "inchesPrinted": 10,
  14.                                 "serialNum" : "111"
  15.                             },
  16.                             {
  17.                                 "deviceModel": "Canon450MX",
  18.                                 "inchesPrinted": 10,
  19.                                 "serialNum" : "222"
  20.                             },
  21.                             {
  22.                                 "deviceModel": "Canon450MX",
  23.                                 "inchesPrinted": 10,
  24.                                 "serialNum" : "333"
  25.                             }
  26.                         ]
  27.                     },
  28.                     {
  29.                         "deviceModel": "HPDeskjet",
  30.                         "devices": [
  31.                             {
  32.                                 "deviceModel": "HPDeskjet",
  33.                                 "inchesPrinted": 20,
  34.                                 "serialNum" : "444"
  35.                             },
  36.                             {
  37.                                 "deviceModel": "HPDeskjet",
  38.                                 "inchesPrinted": 20,
  39.                                 "serialNum" : "555"
  40.                             }
  41.                         ]
  42.                     }
  43.                 ]
  44.             },
  45.             {
  46.                 "datetime": "2014-08-27",
  47.                 "deviceModels": [
  48.                     {
  49.                         "deviceModel": "Canon450MX",
  50.                         "devices": [
  51.                             {
  52.                                 "deviceModel": "Canon450MX",
  53.                                 "inchesPrinted": 5,
  54.                                 "serialNum" : "111"
  55.                             },
  56.                             {
  57.                                 "deviceModel": "Canon450MX",
  58.                                 "inchesPrinted": 25,
  59.                                 "serialNum" : "222"
  60.                             },
  61.                             {
  62.                                 "deviceModel": "Canon450MX",
  63.                                 "inchesPrinted": 15,
  64.                                 "serialNum" : "333"
  65.                             }
  66.                         ]
  67.                     },
  68.                     {
  69.                         "deviceModel": "HPDeskjet",
  70.                         "devices": [
  71.                             {
  72.                                 "deviceModel": "HPDeskjet",
  73.                                 "inchesPrinted": 10,
  74.                                 "serialNum" : "444"
  75.                             },
  76.                             {
  77.                                 "deviceModel": "gx420d",
  78.                                 "inchesPrinted": 20,
  79.                                 "serialNum" : "555"
  80.                             }
  81.                         ]
  82.                     }
  83.                 ]
  84.             }
  85.         ]
  86.     }
  87. ]
  88.  
  89. // I'm aiming for this kind of output
  90. [
  91. { date : 2014-08-26, deviceModel : 'Canon450MX', totalInchesPrinted : 30 },
  92. { date : 2014-08-26, deviceModel : 'HPDeskJet', totalInchesPrinted : 40 },
  93. { date : 2014-08-27, deviceModel : 'Canon450MX', totalInchesPrinted : 45 },
  94. { date : 2014-08-27, deviceModel : 'HPDeskJet', totalInchesPrinted : 30 }
  95. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement