从对象中获取价值

时间:2016-12-21 13:33:01

标签: java mongodb mongodb-query mongodb-java

我的收藏包含以下文件:

{
    "_id": ObjectId("585a7886e4b06aec5d1d1639"),
    "name": "somename",
    "owner": "someowner",
    "slots": 50,
    "gold": 0,
    "tag": "sometext",
    "motd": "sometext",
    "purchases": [],
    "members": {
        "membername1": {
            "rank": 2
        },
        "membername2": {
            "rank": 5
        },
        "membername3": {
            "rank": 3
        }
    }
}

我需要从" members.membername.rank"获取int值。 如何只知道membername?

,我如何得到这个值?

1 个答案:

答案 0 :(得分:0)

以下代码排除了文档的ID,仅获取rank的{​​{1}}

memername1