mirror of
https://github.com/fankes/moshi.git
synced 2025-10-18 23:49:21 +08:00
Add @Json.ignore
(#1417)
* Default Json.name to an unset value * Promote shared transient tests to DualKotlinTest * Add new ignore property to Json * Support it in ClassJsonAdapter * Mention no enum/record support * Support in KotlinJsonAdapter * Rework code gen API to know of "ignored" * Support in apt code gen * Support in KSP * Update old non-working transient example test * Synthetic holders * Use field on both
This commit is contained in:
@@ -79,7 +79,10 @@ final class FallbackEnum {
|
||||
for (int i = 0; i < constants.length; i++) {
|
||||
T constant = constants[i];
|
||||
Json annotation = enumType.getField(constant.name()).getAnnotation(Json.class);
|
||||
String name = annotation != null ? annotation.name() : constant.name();
|
||||
String name =
|
||||
annotation != null && !Json.UNSET_NAME.equals(annotation.name())
|
||||
? annotation.name()
|
||||
: constant.name();
|
||||
nameStrings[i] = name;
|
||||
}
|
||||
options = JsonReader.Options.of(nameStrings);
|
||||
|
Reference in New Issue
Block a user