print(jstr) print("-") # -------------------------------------------------------------------------------------------------------------------- jdict = json.loads(jstr) datum = PathDict(jdict) print(datum) print("=") # -------------------------------------------------------------------------------------------------------------------- path = None print("%s is path: %s is sub-path:%s" % (path, datum.has_path(path), datum.has_sub_path(path))) leaves = datum.paths(path) print("%s: %s" % (path, leaves)) print("-") path = 'val' print("%s is path: %s is sub-path:%s" % (path, datum.has_path(path), datum.has_sub_path(path))) leaves = datum.paths(path) print("%s: %s" % (path, leaves)) print("-") path = 'val.CO' print("%s is path: %s is sub-path:%s" % (path, datum.has_path(path), datum.has_sub_path(path))) leaves = datum.paths(path)
print("-") # -------------------------------------------------------------------------------------------------------------------- jdict = json.loads(jstr, object_pairs_hook=OrderedDict) print(jdict) print("-") datum = PathDict(jdict) print(datum) print("-") path1 = "val.opc.bin1" print("path:%s" % path1) has_path = datum.has_path(path1) print("has_path:%s" % has_path) print("-") path2 = "val.opc.bin1.0" print("path:%s" % path2) has_path = datum.has_path(path2) print("has_path:%s" % has_path) print("-") nodes = datum.node(path1, path2) print("nodes:%s" % str(nodes)) print("=") path = "val.opx.bin1.0"
jstr = JSONify.dumps(datum) print(jstr) print("-") paths = datum.paths() print(paths) print("=") # -------------------------------------------------------------------------------------------------------------------- # Accessing nodes... path1 = "val.opc_n2.bin1" print("path1: %s" % path1) has_path = datum.has_path(path1) print("has_path:%s" % has_path) node = datum.node(path1) print("node: %s" % node) print("-") path2 = "val.opc_n2.bin1.1" print("path2: %s" % path2) has_path = datum.has_path(path2) print("has_path:%s" % has_path) node = datum.node(path2) print("node: %s" % node) print("-")