Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix iOS issue with 0, 1 being interpreted as JSON bools #3285

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions appinventor/components-ios/src/JsonUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,16 @@ fileprivate func convertJsonItem(_ item: AnyObject?, _ useDicts: Bool) -> AnyObj
}
} else if let jsonArray = item as? NSArray {
return getListFromJsonArray(jsonArray, useDicts) as AnyObject
} else if let bool = item as? Bool {
return bool as AnyObject
} else if let number = item as? NSNumber {
if number.isEqual(to: true as NSValue) {
return true as AnyObject
} else if number.isEqual(to: false as NSValue) {
return false as AnyObject
} else {
return number as AnyObject
}
} else if let string = item as? String {
return string as AnyObject
} else if let number = item as? NSNumber {
return number as AnyObject
}
return item.debugDescription as AnyObject
}
Expand Down
6 changes: 4 additions & 2 deletions appinventor/schemekit/src/SCMValue.m
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,10 @@ - (BOOL)isExact {
}

- (pic_value)value {
if (self.isBool) {
return self.boolValue ? pic_true_value(nil) : pic_false_value(nil);
if ([self isEqualToValue:[NSNumber numberWithBool:YES]]) {
return pic_true_value(nil);
} else if ([self isEqualToValue:[NSNumber numberWithBool:NO]]) {
return pic_false_value(nil);
} else if (self.objCType[0] == 'f' || self.objCType[0] == 'd') {
return pic_float_value(nil, self.doubleValue);
} else {
Expand Down