JSON Encoding doesn't store JSON
mark-anders opened this issue · comments
Mark Anders commented
In inspecting the plist files that are created, I was surprised to see that they're not human readable, even though a JSONEncoder is being used. The issue is that you're taking the encoding and storing that directly, rather than converting it to a string.
I think it would be nice to have that at least as an option, to aid in debugging. To do so, you'd change save to look more like:
public func save(_ object: T) throws {
let data = try encoder.encode(object)
if let str = String(data: json, encoding: .utf8) {
store.set(str, forKey: key(for: object))
increaseCounter()
} else {
// throw appropriate error.
}
}
Omar Albeik commented
Hey @mark-anders 👋
Nice Idea, however, I'm not sure if this will have any performance implications
Feel free to open a pull request and I'll make sure to follow up on it