a bunch of guides (such as <the official one>) sug...
# getting-started
y
a bunch of guides (such as the official one) suggest using
Json.decodeFromString(String)
, but I'm not seeing this function on my end. the only one I see is
decodeFromString(DeserializationStrategy<T>, String)
. what gives?
y
I think there's a
reified
version that only works by specifying a type
Json.decodeFromString<MySerializeableType>(string)
or if it can be inferred from context
s
It’s an extension function — do you need to add an import? IDEA isn’t very good at suggesting/adding imports when an extension function shares the same name as a member function, I’ve found.
y
IDEA insists on giving me
kotlinx.serialization.json.Json.Default.decodeFromString
instead of
kotlinx.serialization.decodeFromString
no matter what I do.
I'm on 1.5.0, which seems recent enough.
kotlinx.serialization.json.decodeFromString
does not seem to exist on my copy...?
I guess it's somehow out of date
v
@Youssef Shoaib [MOD] the one you link to is on instances of
StringFormat
Ah, ok,
JsonFormat
is an implementation of
StringFormat
🤦‍♂️
y
I got it working. I'm not sure what the heck I did differently, but it's resolving now.
👌 1
(thanks everyone for the responses)