如何将内容附加到JSON?

时间:2015-08-27 15:56:33

标签: javascript json object grafana

$http({
                    method: 'GET',
                    url: 'xyz'
                }).then(function onSuccess(response) {

                        console.log({"Data Response for dashboard": response});
                    var dashboardData = response.data;},
function onError(response) {
               deferred.reject(response);
                });
                return deferred.promise;};

json file is looks like that {
  "_index": "test",
  "_type": "test",
  "_id": "test",
  "_version": 7,
  "found": true,
  "_source": {
    "user": "guest",
    "group": "guest",
    "title": "test",
    "tags": [
      "test"
    ],
    "dashboard": "{\"id\":null,\"title\":\"dasdasd\",\"originalTitle\":\"sdasdasdas",\"tags\":[\"sdada\"],\"style\":\"dark\",\"timezone\":\"utc\",\"editable\":true,\"hideControls\":false,\"rows\":[{\"title\":\"Delivered\",\"height\":\"300px\",\"editable\":true,\"collapse\":false,\"panels\":[{\"error\":false,\"span\":4,\"editable\":true,\"type\":\"graph\",\"id\":8,\"datasource\":null,\"renderer\":\"flot\",\"x-axis\":true,\"y-axis\":true,\"scale\":1,\"y_formats\":[\"short\",\"short\"],\"grid\":{\"leftMax\":null,\"rightMax\":null,\"leftMin\":0,\"rightMin\":null,\"threshold1\":null,\"threshold2\":null,\"threshold1Color\":\"rgba(216, 200, 27, 0.27)\",\"threshold2Color\":\"rgba(234, 112, 112, 0.22)\"},}
}

现在在json上面我想在面板中添加以下内容(_source.dashboard.rows.panel)“面板”:[

 {
      "id": 1,
      "span": 12,
      "editable": true,
      "type": "text",
      "mode": "html",
      "content": "<div class=\"text-center\" style=\"padding-top: 15px\">\n<img src=\"img/logo_transparent_200x.png\"> \n</div>",
      "style": {},
      "title": "Welcome to"
    }
  ]  

所以我将response.data存储到名为dashboarddata的变量中,以便我可以在面板中添加上面的内容(_source.dashboard.rows.panel)

0 个答案:

没有答案