kriszyp/cbor-x

Unknown tag with map value decode issue

solarw opened this issue · 2 comments

solarw commented

Given: Encoded custom tag with value like: {"type": str, "value": str}.

cbor decode method returns Tag object with proper tag and value == {} (empty map).

if value is something like ["some", "str"], tag.value is correct. not for mapping

so on custom tag value decode, list and string are decoded properly, map is not.

checked payload with cbor playground, to check encoded properly.

looks like cbor-x issue

solarw commented

issue is not correct:

reason was I used

  function decode(data) {
    return new Decoder().decode(data);
  }

and in this case default options for decoding are not applied.
https://github.com/kriszyp/cbor-x/blob/master/decode.js#L39

assume to add

else {options = defaultOptions}

to make defeault options applied on new Decoder()

The exported decode function has different defaults than creating a Decoder instance and using its decode method.