https://kotlinlang.org logo
#serialization
Title
# serialization
j

Jan

01/20/2023, 2:48 PM
Is it possible to get the original property name in a class descriptor, even if it has a
@SerialName
annotation?
a

Adam S

01/20/2023, 3:37 PM
no,
@SerialName
will be the only name that’s in a
SerialDescriptor
why do you want to get the actual property name?
j

Jan

01/21/2023, 11:34 AM
looking for a way to get a KProperty's SerialName and actual name. The KProperty provides the name but there is no way to get the serial name with that name right?
a

Adam S

01/21/2023, 11:40 AM
There might be... It depends on what you want to do. What problem would be solved by having both names?
j

Jan

01/21/2023, 11:45 AM
I mean the problem is Kotlin/JS as you cant get annotations when having a KProperty like Kotlin/JVM. I theoretically only want the serial name but I need to map it to a KProperty
In the end the syntax looks like this:
Copy code
Person::name eq "some name"
On Kotlin/JVM I can just get the SerialName annotation on the KProperty
a

Adam S

01/21/2023, 12:20 PM
Sorry, I don't really understand what you mean. I understand that you want to get the property name and serial name, but what do you want to do with both names? Because there's lots of ways that you might be able to work around it (KSP, a custom annotation...)
4 Views