Skip to content

Commit 56ca55a

Browse files
committed
data: document differences between the native dict format and json
The native dict format is not a 1:1 translation of the JSON format. This was a deliberate design choice to make it easier to work with data nodes in python code. Document the differences. Fixes: #60 Signed-off-by: Robin Jarry <robin@jarry.cc>
1 parent 5b10c43 commit 56ca55a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

libyang/data.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,17 @@ def print_dict(
710710
"""
711711
Convert a DNode object to a python dictionary.
712712
713+
The format is inspired by the YANG JSON format described in :rfc:`7951` but has
714+
some differences:
715+
716+
* ``int64`` and ``uint64`` values are represented by python ``int`` values
717+
instead of string values.
718+
* ``decimal64`` values are represented by python ``float`` values instead of
719+
string values.
720+
* ``empty`` values are represented by python ``None`` values instead of
721+
``[None]`` list instances. To check if an ``empty`` leaf is set in a
722+
container, you should use the idiomatic ``if "foo" in container:`` construct.
723+
713724
:arg bool strip_prefixes:
714725
If True (the default), module prefixes are stripped from dictionary keys. If
715726
False, dictionary keys are in the form ``<module>:<name>``.

0 commit comments

Comments
 (0)