SyntaxError:JSON.parse:期望的属性名称或'}',同时使用highcharts [英] SyntaxError: JSON.parse: expected property name or '}' while using highcharts

查看:295
本文介绍了SyntaxError:JSON.parse:期望的属性名称或'}',同时使用highcharts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用highcharts实现一个折线图,其中我想为特定的点添加颜色。 所以我使用以下声明。

  JSON.parse([{x:1,y:0},{x:2,y:5 ,标记:{填充颜色: '红色'}},{X:3,Y:8}]); 

将点(2,5)着色为红色。



但是,它显示错误为 SyntaxError:JSON.parse:期望的属性名称或'}'

解决方案

有效的JSON字符串 需要 要引用的属性名称。



这可以通过引用下面的属性名称来解决:

  JSON.parse('[{x :1,y:0},{x:2,y:5,marker:{fillColor:red}},{x:3,y:8 }]'); 


I am trying to implement a line chart using highcharts, in which I want to color specific points.

So I am using following statement.

JSON.parse("[{x: 1,y: 0},{x:2,y:5,marker:{fillColor:'red'}},{x:3,y:8}]");

to color the point (2,5) as red.

But, it is showing error as SyntaxError: JSON.parse: expected property name or '}'

解决方案

Valid JSON strings require the property names to be quoted.

This can be corrected by quoting the property names like below:

JSON.parse('[{"x": 1, "y": 0}, {"x":2, "y":5, "marker": {"fillColor":"red"}}, {"x":3, "y":8}]');

这篇关于SyntaxError:JSON.parse:期望的属性名称或'}',同时使用highcharts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆