1) You can't create a JSON from an optional Double, Int, String or Bool. I think a reasonable approach is to turn an optional that is nil into the .null JSON type. This is done via an initializer for example:
let myString: String? = nil
let json = JSON(myString) // becomes .null
2) When you are serializing a JSON dictionary with values that are .null, it would be nice to include an option that skips the key this null is associated with. Some systems prefer the key is not present in the JSON rather than key = null. Both are valid approaches, hence adding in an options parameter to request the skip key behavior.
Fixes #242
This PR addresses two problems:
1) You can't create a JSON from an optional Double, Int, String or Bool. I think a reasonable approach is to turn an optional that is nil into the .null JSON type. This is done via an initializer for example:
2) When you are serializing a JSON dictionary with values that are .null, it would be nice to include an option that skips the key this null is associated with. Some systems prefer the key is not present in the JSON rather than
key = null
. Both are valid approaches, hence adding in anoptions
parameter to request the skip key behavior.