Using @Json(name = "lucky number") is a bit cumbersome for no reason, if we could use another annotation for @JsonName("lucky number"), dropping thename = `, would be a lot quicker with IDE code complete.
Of course, @Json("lucky number") also works, I just think @JsonName() is more readable, but a pure @Json() will be easier for compatibility.
for no reason
That's a bit presumptuous of you! Turns out there is a reason: https://github.com/square/moshi/pull/68#discussion_r36050957
Ouch 馃槩, I am sorry I didn't mean it like that, I meant more on the "no apparent reason" side of things, like "I can't see the reason but there should be one".
Looking at the code you referenced, it's 3 years old and no additions to @Json have been made.... so could @JsonName be a shortcut option to be added to the library? Or maybe just realizing no other options will be placed inside @Json and just add a value option in there?
I don't disagree being the original person who also advocated for value(). Perhaps now is a good time to evaluate whether or not we want to add those proposed features or not.
There is a path to using value(), but it involves allowing someone to write @Json val whatever and having to throw an exception at runtime. But perhaps we're okay with that. Worth figuring it out.
I still like name= here & think the best way to improve the syntax is to by using JSON names that are also valid field names. Names with special characters in 鈥檈m will cause you grief and I prefer to discourage that!
As for required=true, I鈥檇 love to look over our issues & see if there are real problems that extra attributes on the annotation could address.
Most helpful comment
I still like
name=here & think the best way to improve the syntax is to by using JSON names that are also valid field names. Names with special characters in 鈥檈m will cause you grief and I prefer to discourage that!As for required=true, I鈥檇 love to look over our issues & see if there are real problems that extra attributes on the annotation could address.