I'm doing some testing using moshi and trying to s...
# squarelibraries
c
I'm doing some testing using moshi and trying to see what happens when I have a field defined as
val title: String = "default"
, but then my server sends a number by accident. It seems like moshi will convert the json number into a String type. Is that right?
p
Just try it out by parsing a string?
c
Maybe my question was worded bad. I'm trying it out, and it's a string, but I can't believe it. That seems surprising/a mistake? Why would it take a number and convert it to a string.
j
It's there for numeric types that don't fit into the built in numeric types
Like a long with more than 53 bits of precision
c
oh interesting. didn't think about that. ace. thanks
p
Is that standard json?
c
@Paul Woitaschek was that directed to me or to @jessewilson
p
To whoever knows, I don't care where informations come from 😁
j
In Moshi’s API we support reading any number as a string. Our goal was to make it easy to migrate from number to string when you exceed the limits of doubles
👍 1
c
Maybe a stupid question. But is that written in the docs anywhere of these sorts of deserialization "rules" or would you just have to read the src or encounter them yourself to know?
j
It's written in the JsonReader docs
👍 1
c
Thanks. yeah. Just making sure I didn't miss something. The number being turned into a string caught me off guard almost as much as delcaring a non-null type in kotlin, but then using that class in my app without null checking, and then I get a crash report for NPE on something that shouldn't be "possible" to be null. (i understand why that is now, just saying that it did catch me off guard)