Beispiel #1
0
def test_json_query_array():
    json = {
        "abc": "123",
        "another": {
            "nested": "entry"
        },
        "alpha": {
            "array": [1, 2, 3, 4]
        }
    }
    result = _JsonQuery.find(json, "alpha.array[2]")
    assert result == 3
Beispiel #2
0
def test_json_query_nested():
    json = {"abc": "123", "another": {"nested": "entry"}, "alpha": "beta"}
    result = _JsonQuery.find(json, "another.nested")
    assert result == "entry"
Beispiel #3
0
def test_json_query_simple():
    json = {"abc": "123"}
    result = _JsonQuery.find(json, "abc")
    assert result == "123"
def test_json_wildcard_query_array():
    json = {"abc": "123", "another": {"nested": "entry"},
            "alpha": {"array": [1, 2, 3, 4]}}
    result = _JsonQuery.find(json, "alpha.array[*]")
    assert result == [1, 2, 3, 4]
def test_json_query_nested():
    json = {"abc": "123", "another": {"nested": "entry"}, "alpha": "beta"}
    result = _JsonQuery.find(json, "another.nested")
    assert result == "entry"
def test_json_query_simple():
    json = {"abc": "123"}
    result = _JsonQuery.find(json, "abc")
    assert result == "123"