fson icon indicating copy to clipboard operation
fson copied to clipboard

Support default values in fson_get for non-existent paths

Open fangq opened this issue 4 years ago • 0 comments

First, thank you for this wonderful library!

I just added fson to one of my f90 projects and decided to make fson_get calls to accept default values when a specified path does not exist. This is very convenient and allows one to use compact JSON inputs without needing all keys to present.

The default values are added as an optional argument to fson_get and should be fully backward compatible to existing codes. See updated sample code here:

https://github.com/fangq/fson/commit/6578fd2f5f3b014ebaf4dfed594792e8b75c2757#diff-084560e84ee2315a2388956bd315c7dcR63

If you are interested, feel free to take this patch and merge it to the upstream code. Suggestions on additional changes are welcome.

fangq avatar May 09 '20 19:05 fangq