automerge / automerge-swift

Swift language bindings presenting Automerge
https://automerge.org/automerge-swift/documentation/automerge/
MIT License
216 stars 11 forks source link

Fix error when decoding int as double #153

Closed bgomberg closed 2 months ago

bgomberg commented 2 months ago

I found that if I create an Automerge document in Javascript with a field being defined as a number, assign an integer value into it, and then try to load that document in Swift, I get an error saying Expected to decode Double but found ScalarValue<Int(5)> instead.. I would expect the decoder to just handle casting ints to doubles, as this is what the Swift JSON decoder does. This PR updates the behavior to match that expectation.

heckj commented 2 months ago

Thank you @bgomberg - looks great!