diff --git a/Sources/ToJSON.swift b/Sources/ToJSON.swift index 311d1d51..4b73fdaa 100644 --- a/Sources/ToJSON.swift +++ b/Sources/ToJSON.swift @@ -103,7 +103,7 @@ internal final class ToJSON { } class func object(_ field: N, map: Map) { - if let result = Mapper(context: map.context).toJSON(field) as Any? { + if let result = Mapper(context: map.context, shouldIncludeNilValues: map.shouldIncludeNilValues).toJSON(field) as Any? { setValue(result, map: map) } } @@ -115,7 +115,7 @@ internal final class ToJSON { } class func objectArray(_ field: Array, map: Map) { - let JSONObjects = Mapper(context: map.context).toJSONArray(field) + let JSONObjects = Mapper(context: map.context, shouldIncludeNilValues: map.shouldIncludeNilValues).toJSONArray(field) setValue(JSONObjects, map: map) } @@ -129,7 +129,7 @@ internal final class ToJSON { class func twoDimensionalObjectArray(_ field: Array>, map: Map) { var array = [[[String: Any]]]() for innerArray in field { - let JSONObjects = Mapper(context: map.context).toJSONArray(innerArray) + let JSONObjects = Mapper(context: map.context, shouldIncludeNilValues: map.shouldIncludeNilValues).toJSONArray(innerArray) array.append(JSONObjects) } setValue(array, map: map) @@ -142,7 +142,7 @@ internal final class ToJSON { } class func objectSet(_ field: Set, map: Map) where N: Hashable { - let JSONObjects = Mapper(context: map.context).toJSONSet(field) + let JSONObjects = Mapper(context: map.context, shouldIncludeNilValues: map.shouldIncludeNilValues).toJSONSet(field) setValue(JSONObjects, map: map) } @@ -154,7 +154,7 @@ internal final class ToJSON { } class func objectDictionary(_ field: Dictionary, map: Map) { - let JSONObjects = Mapper(context: map.context).toJSONDictionary(field) + let JSONObjects = Mapper(context: map.context, shouldIncludeNilValues: map.shouldIncludeNilValues).toJSONDictionary(field) setValue(JSONObjects, map: map) } @@ -166,7 +166,7 @@ internal final class ToJSON { } class func objectDictionaryOfArrays(_ field: Dictionary, map: Map) { - let JSONObjects = Mapper(context: map.context).toJSONDictionaryOfArrays(field) + let JSONObjects = Mapper(context: map.context, shouldIncludeNilValues: map.shouldIncludeNilValues).toJSONDictionaryOfArrays(field) setValue(JSONObjects, map: map) }