1

我的 json 和查询的图像

在此处输入图像描述

json代码

{
    "reading_list": {
        "book": {
            "name": "Fifty shades of grey",
            "author": "E.L James",
            "date": "March 2015",
            "comment": "did not like it very much"
        },
        "book": {
            "name": "The grass is singing",
            "author": "Doris Lessing",
            "date": "April 2015",
            "comment": "enjoyed it quite a bit"
        },
        "book": {
            "name": "A short history of nearly everything",
            "author": "Bill Bryson",
            "date": "June 2015",
            "comment": "very informative"
        },
        "book": {
            "name": "JSON in 24 hours",
            "author": "Peter Settler",
            "date": "in the year",
            "comment": "read for work"
        },
        "book": {
            "name": "Miss Smilla's feeling for snow",
            "author": "Peter Hoeg's",
            "date": "in the year",
            "comment": "read for entertainment"
        }
    }
}

查询代码:

for $x in reading_list
return $x("book")/name

正如您从链接中看到的那样,我希望得到所有的书名,但我只得到:

Miss Smilla's feeling for snow.
The output should be like this:
Fifty shades of grey
A short history of nearly everything
The grass is singing
JSON in 24 hours
Miss Smilla's feeling for snow

出了什么问题?..请帮忙

4

1 回答 1

0

在 JSONiq 数据模型 (JDM) 中,不允许重复键(例如您的示例中的 book)。似乎此实现不会引发错误,而是使用该密钥的最后一对。

原始 JSON RFC中,这个约束是一个应该。您可以通过将阅读列表建模为书籍数组来增加互操作性。

于 2016-03-24T07:52:55.920 回答