JSON to string variable dump

前端 未结 5 1648
长发绾君心
长发绾君心 2020-12-02 10:15

Is there a quick function to convert JSON objects received via jQuery getJSON to a string variable dump (for tracing/debugging purposes)?

5条回答
  •  爱一瞬间的悲伤
    2020-12-02 10:50

    You can use console.log() in Firebug or Chrome to get a good object view here, like this:

    $.getJSON('my.json', function(data) {
      console.log(data);
    });
    

    If you just want to view the string, look at the Resource view in Chrome or the Net view in Firebug to see the actual string response from the server (no need to convert it...you received it this way).

    If you want to take that string and break it down for easy viewing, there's an excellent tool here: http://json.parser.online.fr/

提交回复
热议问题