getJSON to console.log() to output json structure

前端 未结 2 677
北恋
北恋 2020-12-24 11:06

I have the following code for getting json data:

$.getJSON( \"assessments\", function( assessments ) {
    console.log(assessments);
        });
相关标签:
2条回答
  • 2020-12-24 11:39

    Stringify the JSON with indentation like so :

    $.getJSON( "assessments", function( assessments ) {
        console.log(JSON.stringify(assessments, undefined, 2))
    });
    

    JSON.stringify(value[, replacer [, space]]) where space is the indent. MDN

    0 讨论(0)
  • 2020-12-24 11:48

    try with

    console.log(JSON.stringify(assessments));
    
    0 讨论(0)
提交回复
热议问题