This is a migrated thread and some comments may be shown as answers.

Cannot provide a number as a key in JSON - get an "Unexpected number" error.

1 Answer 50 Views
Charts
This is a migrated thread and some comments may be shown as answers.
AP
Top achievements
Rank 1
AP asked on 23 Jan 2013, 11:22 AM
Hello, 

If I provide this simple data to a chart, the chart data shows up correctly.
var data = [
                {"state":"NY","abc":12312},
                {"state":"AZ","abc":12312},
                {"state":"CA","abc":12312},
                {"state":"VT","abc":12312}
            ];
Please note that the above JSON has STRINGS for the keys.

However, if I provide a number as a key, I get an "Unexpected number at line number 2156" error.

var data = [
                {"state":"MH","1":12312},
                {"state":"MH","1":12312},
                {"state":"MH","1":12312},
                {"state":"MH","1":12312}
            ];

Any help?

1 Answer, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 24 Jan 2013, 04:24 PM
Hello,

In order to get the desired outcome you can pass an array to the series. I.e.:

$("#chart").kendoChart({
  //...
  dataSource: {
      data: [
         {"state":"MH","1":12312},
         {"state":"MH","1":12312},
         {"state":"MH","1":12312},
         {"state":"MH","1":12312}]
  },
  series: [{
      field: "['1']"
  }]
})

For a working example please check this jsBin example.

Regards,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Charts
Asked by
AP
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Share this question
or