How to see a json object's format?

This question already has an answer here:

  • How can I beautify JSON programmatically? [duplicate] 2 answers

  • The result of your HTTP request is a string. So you do :

    jsonResult = JSON.parse(result);
    

    to parse this string (result) in an object (jsonResult).

    So if you want to see this json as a string, you just have to :

    console.log(result);
    

    Or add it to an element


    are you using a python interpreter to do this?

    If so you can use "pretty printing" which should display the son file in a nice way.

    >>> import json
    >>> print json.dumps({'4': 5, '6': 7}, sort_keys=True,
    ...                  indent=4, separators=(',', ': '))
    {
        "4": 5,
        "6": 7
    }
    

    Taken from: https://docs.python.org/2/library/json.html

    EDIT:

    Sorry just seen that you are using JS. How can I pretty-print JSON using JavaScript?

    perhaps this helps.

    链接地址: http://www.djcxy.com/p/48194.html

    上一篇: JSON.Stringify与intendation

    下一篇: 如何查看json对象的格式?