Home forums Using CanvasJS Ignore part of JSON

Tagged: , ,

This topic contains 1 reply, has 2 voices, and was last updated by  Vishwas R 2 months, 3 weeks ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #22640

    wonky
    Member

    The API I am hitting returns something like {“Success”:true,”Error”:null,”Data”:[{

    I only want the “Data”

    Does CanvasJS have a syntax for picking at the API JSON?

    #22647

    Vishwas R
    Keymaster

    @wonky,

    CanvasJS just renders the chart with the data that you have passed in chart-option. You can use AJAX getJSON to get the JSON data and with the help of key, you can get its corresponding value. Please refer this tutorial for the same.

    Example: If you are storing json {"Success":true,"Error":null,"Data":[{}]} as test.json, you can access Data using jsonData.Data where jsonData is the response that you get from AJAX request.

    
    $.getJSON("test.js", function(jsonData) {
        var data = jsonData.Data;
     });
    


    Vishwas R
    Team CanvasJS

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.