使用GSON API解析JSON数据

时间:2019-03-30 03:34:52

标签: json gson

我有一个JSON数据,并且能够将JSON数据转换为字符串。

我希望一个个地从根对象中获取一个json数组(如果有很多,则使用循环)

返回的对象必须为“ com.google.gson.JsonObject ”类型,因为另一种方法将此对象作为输入来获取属性值。

我的json看起来像这样:

我将需要“ 资源”中的json数组-

{
    "totalResults": 2,
    "startIndex": 1,
    "schemas": [
        "urn:ietf:params:scim:api:messages:2.0:ListResponse"
    ],
    "Resources": [
        {
            "owner": {},
            "application": {
                "displayName": "Non Auth App",
                "value": "4028b88168fa3d38016900d1759405a6",
                "$ref": "http://localhost:8080/identityiq/scim/v2/Applications/4028b88168fa3d38016900d1759405a6"
            },
            "meta": {
                "created": "2019-03-22T18:40:30.505+05:30",
                "location": "http://localhost:8080/identityiq/scim/v2/Entitlements/297eff8a699f8b3a0169a5863769008b",
                "version": "W/\"1553260230505\"",
                "resourceType": "Entitlement"
            },
            "schemas": [
                "urn:ietf:params:scim:schemas:sailpoint:1.0:Entitlement"
            ],
            "displayableName": "reader",
            "aggregated": false,
            "id": "297eff8a699f8b3a0169a5863769008b",
            "requestable": true,
            "attribute": "Privileges",
            "type": "Entitlement",
            "descriptions": [],
            "value": "reader"
        },
        {
            "owner": {},
            "application": {
                "displayName": "Non Auth App",
                "value": "4028b88168fa3d38016900d1759405a6",
                "$ref": "http://localhost:8080/identityiq/scim/v2/Applications/4028b88168fa3d38016900d1759405a6"
            },
            "meta": {
                "created": "2019-03-18T19:11:47.912+05:30",
                "location": "http://localhost:8080/identityiq/scim/v2/Entitlements/297eff8a6990fc49016991096d08001e",
                "version": "W/\"1552916507912\"",
                "resourceType": "Entitlement"
            },
            "schemas": [
                "urn:ietf:params:scim:schemas:sailpoint:1.0:Entitlement"
            ],
            "displayableName": "admin",
            "aggregated": false,
            "id": "297eff8a6990fc49016991096d08001e",
            "requestable": true,
            "attribute": "Privileges",
            "type": "Entitlement",
            "descriptions": [],
            "value": "admin"
        }
    ]
}

感谢您的帮助。

0 个答案:

没有答案