diff --git a/README.md b/README.md index c93f34e..01223f0 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ Dictionary ```python collections.defaultdict() # Creates a dictionary with default values. +collections.OrderedDict() # Creates ordered dictionary. dict() # Initiates a dict from list of key/value pairs. dict(zip(keys, values)) # Initiates a dict from two lists. {k: v for k, v in .items() if k in } # Filters a dict by keys. @@ -528,7 +529,13 @@ import json ### Serialization ```python = json.dumps(, ensure_ascii=True, indent=None) - = json.loads() + = json.loads() +``` + +#### To preserve order: +```python +from collections import OrderedDict + = json.loads(, object_pairs_hook=OrderedDict) ``` ### Read File