是否可以在不读取所有值的情况下提取JSON数据中的特定数据

时间:2011-09-15 09:10:52

标签: json

我有这个JSON数据。 我的问题是,是否可以在不读取所有值的情况下提取JSON数据中的特定数据。 我的意思是可以像在SQL中一样查询数据吗?

   { "_id" : ObjectId("4e61501e6a73bc73f82f91f3"), "created_at" : "2011-09-02 17:52:30.285", "cust_id" : "sdtest", "moduleName" : "balances", "responses" : [
            {
                    "questionNum" : "1",
                    "answer" : "Hard",
                    "comments" : "is that you john wayne?"
            },
            {
                    "questionNum" : "2",
                    "answer" : "Somewhat",
                    "comments" : "ARg!"
            },
            {
                    "questionNum" : "3",
                    "answer" : "",
                    "comments" : "Yes"
            }
    ] }

2 个答案:

答案 0 :(得分:0)

是的,但您需要编写额外的代码才能执行此操作,或使用第三方库。有一些可用:http://www.google.co.uk/search?q=json+linq+sql

答案 1 :(得分:0)

好吧,除非你使用incremental JSON解析器,否则你必须先解析整个JSON。之后,它取决于您的编程语言的过滤能力。例如,在Python中

import json
obj = json.loads(jsonData)
answeredQuestions = filter(lambda response: response.answer, obj["responses"])
相关问题