如何在JSON中查找字段

时间:2011-03-10 12:16:39

标签: json

// JSON
{
"items": [
  {
    "title": "welcoem home",
    "author": "Charles Dickens"
  },
  {
    "title": "Harry Potter",
    "author": "J rowling"
  }]
}

这是我的json脚本..我需要从中找到“items”,title和author字段及其值。我正在使用参考system.net.json。

1 个答案:

答案 0 :(得分:0)

在python中?

data = """
{ "items": [ { "title": "welcoem home", "author": "Charles Dickens" }, { "title": "Harry Potter", "author": "J rowling" }] }
"""

import json
data2 = json.loads(data)
authors = [x['author'] for x in data2['items']]