Re: Default value for missing JSON fields

2019-01-02 Thread jegfish
Could you (or anyone else) please provide guidance as to what I could do to preserve an easy to use interface for users of my library? Currently I have 2 ideas. * The first is to define types with the appropriate private fields for the JSON and defining exported getter procedures for people

Re: Default value for missing JSON fields

2019-01-01 Thread dom96
Sadly you have to use an `Option` in this case. I'm afraid the to macro doesn't support anything else.

Default value for missing JSON fields

2018-12-31 Thread jegfish
I am trying to write a wrapper for a JSON API and I want to map its JSON objects to custom Nim objects. I am having trouble figuring out what to do with fields that aren't always provided in the JSON objects. import json type Type = object # Normal field,