Skip to content

Commit

Permalink
Avoid JSON cache by JSONSerialization NSString (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgoncal committed Apr 22, 2024
1 parent 069a135 commit 226008d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Source/Data/HADataDecodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ public extension HAData {
}

if let value = value as? T {
return value
// Avoid full JSON cache when using JSONSerialization and referencing NSString
if var valueString = value as? String {
valueString.makeContiguousUTF8()
return valueString as? T ?? value
} else {
return value
}
}

throw HADataError.incorrectType(
Expand Down

0 comments on commit 226008d

Please sign in to comment.