Skip to content

Commit 1d464ca

Browse files
Fix edge-case boolean deserialization in RedisObjectHandler.SendToJson (#519)
Address boolean deserialization from JSON when the value may be represented as a number (#518) Co-authored-by: Mark Faulcon <[email protected]>
1 parent f7d8778 commit 1d464ca

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,7 @@ This approach is particularly useful for services deployed to Azure, as it allow
619619
* [@ahmedisam99](https://github.com/ahmedisam99)
620620
* [@kirollosonsi](https://github.com/kirollosonsi)
621621
* [@tgmoore](https://github.com/tgmoore)
622+
* [@mfaulcon](https://github.com/mfaulcon)
622623
623624
<!-- Logo -->
624625
[Logo]: images/logo.svg

src/Redis.OM/RedisObjectHandler.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,13 @@ private static string SendToJson(IDictionary<string, RedisReply> hash, Type t)
497497
continue;
498498
}
499499

500-
ret += $"\"{propertyName}\":{((string)hash[lookupPropertyName]).ToLower()},";
500+
var propValue = ((string)hash[lookupPropertyName]).ToLower();
501+
propValue = propValue == "0"
502+
? "false"
503+
: propValue == "1"
504+
? "true"
505+
: propValue;
506+
ret += $"\"{propertyName}\":{propValue},";
501507
}
502508
else if (type.IsPrimitive || type == typeof(decimal) || type.IsEnum)
503509
{

0 commit comments

Comments
 (0)