How to read json file with optional entries and entries with different types #1281
Labels
kind: question
solution: proposed fix
a fix for the issue has been proposed and waits for confirmation
First of all thansks for this fantastic library. It got me reading dozens of json test files withing minutes.
How do I read from a json file with test vectors in which have optional entries as well as entries that can change the type of the value?
I am wondering how to go about writing the
to_json/from_json
methods. I particularly I am interested in thefrom_json
to start with. Some of the entries as shown in the example below are optional. For example, the decoded entry as well as the diagnostic entry may or may not appear for each object. Additionally the decoded entry could have values of different types i.einteger
,double
orstring
. So I just need to read them out of the file in the best way possible.So I have figured out how to do this for the first three entries(cbor, hex, roundtrip) that are always present and don't morph into different types. Could I please have some advice how to handle the other two optional and mutating entries i.e. decoded and diagnostic?
thanks very much as I am sure there is a way of doing this but cannot just see it for now.
the complete file with test vectors is locate here
The text was updated successfully, but these errors were encountered: