Javascript 将json输入到变量中,然后将其传递

Javascript 将json输入到变量中,然后将其传递,javascript,jquery,json,highcharts,highstock,Javascript,Jquery,Json,Highcharts,Highstock,如果我们有这样的代码 yAxis : { title : { text : 'Exchange rate' }, plotLines : [{ value : 0.6738, color : 'green', dashStyle : 'shortdash', wid

如果我们有这样的代码

 yAxis : {
            title : {
                text : 'Exchange rate'
            },
            plotLines : [{
                value : 0.6738,
                color : 'green',
                dashStyle : 'shortdash',
                width : 2,
                label : {
                    text : 'Last quarter minimum'
                }
            }, {
                value : 0.7419,
                color : 'red',
                dashStyle : 'shortdash',
                width : 2,
                label : {
                    text : 'Last quarter maximum'
                }
            }]
        },
 var jsonObj = [];
 jsonObj.push({ "value": 1256211571000, "color": '#D2691E', "width": 1, "label": {   "text": 'rinse'} });
        var myLines = JSON.stringify(jsonObj);
如何获取plotlines json字符串并将其指定给变量,然后将此变量传递给plotline对象??? 我试过这样的东西

 yAxis : {
            title : {
                text : 'Exchange rate'
            },
            plotLines : [{
                value : 0.6738,
                color : 'green',
                dashStyle : 'shortdash',
                width : 2,
                label : {
                    text : 'Last quarter minimum'
                }
            }, {
                value : 0.7419,
                color : 'red',
                dashStyle : 'shortdash',
                width : 2,
                label : {
                    text : 'Last quarter maximum'
                }
            }]
        },
 var jsonObj = [];
 jsonObj.push({ "value": 1256211571000, "color": '#D2691E', "width": 1, "label": {   "text": 'rinse'} });
        var myLines = JSON.stringify(jsonObj);

然后将mylines传递给plotlines,但它实际上不起作用

假设此对象位于名为
data
的变量中,只需执行以下操作:

data.yAxis.plotLines.push({
    "value": 1256211571000,
    "color": '#D2691E',
    "width": 1,
    "label": {
        "text": 'rinse'
    }
});

这只是一个JavaScript对象,而不是JSON。JSON是对象(或数组)的字符串表示形式。

这里是一个示例,如果它适合您的话 "

$(文档).ready(函数(){

$.getJSON('yourpage.php?getdata=y&compid=',函数(数据){
//将数据集拆分为ohlc和卷
var ohlc=[],
卷=[],
dataLength=data.length;
对于(i=0;i
您想做什么?为什么要使用JSON.stringify?“将变量传递给对象”是什么意思?