Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mcmcgrath13/dotmaps.jl
Dot notation indexing of Dictionaries
https://github.com/mcmcgrath13/dotmaps.jl
Last synced: 11 days ago
JSON representation
Dot notation indexing of Dictionaries
- Host: GitHub
- URL: https://github.com/mcmcgrath13/dotmaps.jl
- Owner: mcmcgrath13
- License: mit
- Created: 2020-06-05T19:20:04.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-10-23T00:39:52.000Z (about 4 years ago)
- Last Synced: 2024-10-15T07:35:08.543Z (about 1 month ago)
- Language: Julia
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DotMaps
[![Build Status](https://github.com/mcmcgrath13/DotMaps.jl/workflows/CI/badge.svg)](https://github.com/mcmcgrath13/DotMaps.jl/actions)
A wrapper for dictionaries that allows dot notation indexing as well as traditional bracket indexing.
```julia
dict = Dict("a"=>1, "b"=>2, "c" => Dict("d"=>3))
dm = DotMap(dict)dm.c.d # returns 3
dm.c.e = 5
dm["c"].e # returns 5DotMap.todict(dm, keys_as_strings=true) # returns Dict("a"=>1, "b"=>2, "c" => Dict("d"=>3, "e"=>5))
DotMap.todict(dm) # returns Dict(:a=>1, :b=>2, :c => Dict(:d=>3, :e=>5))
```**NOTE** This is not as performative as using normal dictionaries, but is nice for accessing deeply nested dictionary structures, such as large config/yaml/json files.