Created
October 25, 2022 05:06
-
-
Save iisaka51/4a5c4aa888157ad2dc6bf5c42f795371 to your computer and use it in GitHub Desktop.
uDict example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In [1]: from datajuggler import uDict, Keylist, Keypath | |
In [2]: data = { "a": 1, | |
...: "b": { "c": { "x": 2, "y": 3, }, | |
...: "d": { "x": 4, "y": 5, }, | |
...: "e": [ { "x": 1, "y": -1, "z": [101, 102, 103], }, | |
...: { "x": 2, "y": -2, "z": [201, 202, 203], }, | |
...: { "x": 3, "y": -3, "z": [301, 302, 303], }, | |
...: ], | |
...: }, | |
...: } | |
In [3]: d = uDict(data) | |
In [4]: d['a'] | |
Out[4]: 1 | |
In [5]: d[Keylist(['b', 'e[1]', 'z[2]'])] | |
Out[5]: 203 | |
In [6]: d[Keypath('b.e[1].z[2]')] | |
Out[6]: 203 | |
In [7]: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment