2
i have the values in taglist variable is like 

{
  "y-range": [{
  "min": "0.0",
  "max": "74.0"
 }],
"points": {
"SysPerfDiskTime": [{
        "dateTime": "2016-03-29 03:25:37",
        " value": "7.0"
       }, 
       {
        "dateTime": "2016-03-29 03:25:39",
        "value": "7.0"
       }, 
       {
        "dateTime": "2016-03-29 03:25:41",
        "value": "21.0"
       }, 
       {
        "dateTime": "2016-03-29 03:30:37",
        "value": "2.0"
        }],
"SysTimeSec": [{
    "dateTime": "2016-03-29 03:25:37",
    "value": "37.0"
    }, 
    {
        "dateTime": "2016-03-29 03:25:39",
        "value": "39.0"
     }, 
     {
        "dateTime": "2016-03-29 03:25:41",
        "value": "41.0"
     }, 
     {
        "dateTime": "2016-03-29 03:25:43",
        "value": "43.0"
      },
      {
        "dateTime": "2016-03-29 03:25:45",
        "value": "45.0"
      }, 
      {
        "dateTime": "2016-03-29 03:25:47",
        "value": "47.0"
      }, 
      {
        "dateTime": "2016-03-29 03:25:49",
        "value": "49.0"
     }, 
     {
        "dateTime": "2016-03-29 03:25:51",
        "value": "51.0"
    }, 
    {
        "dateTime": "2016-03-29 03:30:37",
        "value": "37.0"
    }]
}}

and i am using the below code to fetch the points data in ejs file

  <% for (var i=0; i < tags.length; i++)
  {
  console.log(tags[i]);
 var data= points.points.tags[i];
 console.log(data);
  }
  %>

tag variable have data [ 'SysPerfDiskTime', 'SysTimeSec' ]

what is the best way to get the points datafrom json object.

Akhilesh Singh
  • 1,724
  • 2
  • 19
  • 35
Sumit Aggarwal
  • 831
  • 2
  • 16
  • 29

1 Answers1

0

In your code :

 console.log(tags[i]);
 var data= points.points.tags[i];
 console.log(data);

You have tags and points.points.tags I think you only meant to use tags so:

 console.log(tags[i]);
 var data= tags[i];
 console.log(data);
basarat
  • 261,912
  • 58
  • 460
  • 511