Parsing and printing JSON data using Python

前端 未结 5 1031
臣服心动
臣服心动 2020-12-22 06:32

I\'m new to JSON and I\'m working on extracting values from JSON data using Python. I\'m getting the JSON data using another shell script with cURL.

Here is my JSON

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-22 07:19

    Your data is multiple json objects.

    You may want to wrap it in curly brackets ({ and }) and treat it as one unique set of all your objects.

    {
    {"preview":true,"offset":0,"result":{"Country":"AU","count":"417"}}
    {"preview":true,"offset":1,"result":{"Country":"BG","count":"7"}}
    {"preview":true,"offset":2,"result":{"Country":"CA","count":"198"}}
    {"preview":true,"offset":3,"result":{"Country":"CH","count":"1"}}
    {"preview":true,"offset":4,"result":{"Country":"CN","count":"3"}}
    {"preview":true,"offset":5,"result":{"Country":"CR","count":"1"}}
    {"preview":true,"offset":6,"result":{"Country":"DE","count":"148"}}
    {"preview":true,"offset":7,"result":{"Country":"DK","count":"1"}}
    {"preview":true,"offset":8,"result":{"Country":"FI","count":"1"}}
    {"preview":true,"offset":9,"result":{"Country":"FR","count":"1052"}}
    {"preview":true,"offset":10,"result":{"Country":"GB","count":"1430"}}
    {"preview":true,"offset":11,"result":{"Country":"HK","count":"243"}}
    {"preview":false,"offset":12,"lastrow":true,"result":{"Country":"VG","count":"54"}}
    }
    

提交回复
热议问题