JSONata,从嵌套对象中提取数据

时间:2018-03-22 15:06:00

标签: jsonata

我是JSONata的新手,所以仍然可以理解它。我需要从嵌套对象中提取数据,例如:

{
    "transaction": {
        "id": "de112b4b-82e2-4172-a89f-68724c90b692"
    },
    "domain": {
        "id": "realworld"
    },
    "listing": {
        "spanner": {
            "information": {
                "type": {
                    "VENDOR": "Charlie"
                },
                "variables": {
                },
                "uid": "08_spanner",
                "mode": {
                    "store": "bob"
                },
                "version": "1",
                "name": "Harrold"
            }
        },
        "hammer": {
            "information": {
                "type": {
                    "VENDOR": "Cliff"
                },
                "variables": {
                },
                "uid": "08_hammer",
                "mode": {
                    "store": "steve"
                },
                "version": "1",
                "name": "Mike"
            }
        },
        "wrench": {
            "information": {
                "type": {
                    "VENDOR": "Dave"
                },
                "variables": {
                },
                "uid": "08_wrench",
                "mode": {
                    "store": "bob"
                },
                "version": "1",
                "name": "Kent"
            }
        }
    }
}

...我需要用它的“信息”来提取列表数据,但没有信息密钥。结果如下:

{
    "spanner": {
        "type": {
            "VENDOR": "Charlie"
        },
        "variables": {
        },
        "uid": "08_spanner",
        "mode": {
            "store": "bob"
        },
        "version": "1",
        "name": "Harrold"
    },
    "hammer": {
        "type": {
            "VENDOR": "Cliff"
        },
        "variables": {
        },
        "uid": "08_hammer",
        "mode": {
            "store": "steve"
        },
        "version": "1",
        "name": "Mike"
    },
    "wrench": {
        "type": {
            "VENDOR": "Dave"
        },
        "variables": {
        },
        "uid": "08_wrench",
        "mode": {
            "store": "bob"
        },
        "version": "1",
        "name": "Kent"
    }
}

我一直在讨论http://try.jsonata.org/并且可以看到图书馆有多强大,但到目前为止还没有成功实现这一目标。任何和所有的帮助表示赞赏:)。

1 个答案:

答案 0 :(得分:1)

以下表达式将执行此操作:

- (void) viewDidLoad {
_originalValues = @{
                    @124: [UIImage imageNamed:@"anyImageName"],
                    @125: [UIImage imageNamed:@"anyImageName"],
                    @126: [UIImage imageNamed:@"anyImageName"],
                    };
}

请参阅http://try.jsonata.org/S17Erm85z