From 0736303c179ee1592194ae206ba52fadd6224e51 Mon Sep 17 00:00:00 2001 From: frranck Date: Tue, 6 Sep 2016 14:08:16 +0200 Subject: [PATCH] Accept other options for Booleans values Hello, We noticed (incorrect but ) booleans values in JSON returned were failing. With this change this JSON would accepted: { "testBool": "True", "testBool2": "False", "testBool3": "T", "testBool4": "F", "testBool5": "NO", "testBool6": "YES" } --- Sources/Unbox.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/Unbox.swift b/Sources/Unbox.swift index 59faca9..685c32a 100644 --- a/Sources/Unbox.swift +++ b/Sources/Unbox.swift @@ -219,6 +219,12 @@ extension Bool: UnboxableRawType { } public static func transformUnboxedString(unboxedString: String) -> Bool? { + for element in [ "true", "t" , "y", "yes" ] where element.uppercased() == unboxedString.uppercased() { + return true + } + for element in [ "false", "f" , "n", "no" ] where element.uppercased() == unboxedString.uppercased() { + return false + } return nil } }