Skip to content

Commit 7076c3a

Browse files
committed
Support more boolean values
1 parent 2269b3e commit 7076c3a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Sources/DynamicJSON/DynamicJSON.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ public enum DynamicJSON: Decodable {
149149
return intVal
150150
} else if let doubleVal = Double(str) {
151151
return Int(doubleVal)
152-
} else if ["true", "yes", "on"].contains(str.lowercased()) {
152+
} else if ["1", "true", "yes", "on", "enabled", "active", "authorized", "valid"].contains(str.lowercased()) {
153153
return 1
154-
} else if ["false", "no", "off"].contains(str.lowercased()) {
154+
} else if ["0", "false", "no", "off", "disabled", "inactive", "unauthorized", "invalid"].contains(str.lowercased()) {
155155
return 0
156156
}
157157
return nil
@@ -170,9 +170,9 @@ public enum DynamicJSON: Decodable {
170170
return doubleVal
171171
} else if let intVal = Int(str) {
172172
return Double(intVal)
173-
} else if ["true", "yes", "on"].contains(str.lowercased()) {
173+
} else if ["1", "true", "yes", "on", "enabled", "active", "authorized", "valid"].contains(str.lowercased()) {
174174
return 1.0
175-
} else if ["false", "no", "off"].contains(str.lowercased()) {
175+
} else if ["0", "false", "no", "off", "disabled", "inactive", "unauthorized", "invalid"].contains(str.lowercased()) {
176176
return 0.0
177177
}
178178
return nil

0 commit comments

Comments
 (0)