def decode_hash(self, hash, cache, as_map_key): if len(hash) != 1: h = {} for k, v in hash.items(): # crude/verbose implementation, but this is only version that # plays nice w/cache for both msgpack and json thus far. # -- e.g., we have to specify encode/decode order for key/val # -- explicitly, all implicit ordering has broken in corner # -- cases, thus these extraneous seeming assignments key = self._decode(k, cache, True) val = self._decode(v, cache, False) h[key] = val return transit_types.frozendict(h) else: key,value = hash.items()[0] key = self._decode(key, cache, True) if isinstance(key, Tag): return self.decode_tag(key.tag, self._decode(value, cache, as_map_key)) else: return transit_types.frozendict({key: self._decode(value, cache, False)})
def decode_hash(self, hash, cache, as_map_key): if len(hash) != 1: h = {} for k, v in hash.items(): # crude/verbose implementation, but this is only version that # plays nice w/cache for both msgpack and json thus far. # -- e.g., we have to specify encode/decode order for key/val # -- explicitly, all implicit ordering has broken in corner # -- cases, thus these extraneous seeming assignments key = self._decode(k, cache, True) val = self._decode(v, cache, False) h[key] = val return transit_types.frozendict(h) else: key, value = hash.items()[0] key = self._decode(key, cache, True) if isinstance(key, Tag): return self.decode_tag(key.tag, self._decode(value, cache, as_map_key)) else: return transit_types.frozendict( {key: self._decode(value, cache, False)})
def from_rep(cmap): return transit_types.frozendict(pairs(cmap))