Hi Can anybody explain the difference between usi...
# ktor
c
Hi Can anybody explain the difference between using field
@field:JsonProperty("foo")
and without field
@JsonProperty("foo")
When should i use when
g
First one annotates field of property.
Second one annotate element depending on context
Check official docs https://kotlinlang.org/docs/reference/annotations.html#annotation-use-site-targets
Copy code
If you don't specify a use-site target, the target is chosen according to the @Target annotation of the annotation being used. If there are multiple applicable targets, the first applicable target from the following list is used:

param;
property;
field.
💯 2