Skip to content

Want to change @JsonProperty property in the java model which is being created from TypeSpec. #4207

Closed Answered by weidongxu-microsoft
shikshartin-coder asked this question in Q&A
Discussion options

You must be logged in to vote

I am not sure whether I get the question.

I assume you are talking about a property with name e.g. "foo" in TypeSpec, but you want @JsonProperty("bar") instead for it.

There is an @encodedName decorator that modifies the "wire name" (the name of the property in the JSON payload).
E.g. https://github.com/Azure/typespec-azure/blob/main/packages/azure-http-specs/specs/client/naming/main.tsp#L37-L38
It means, when serialize/de-serialize for "application/json" content-type, use "wireName" as JSON property name, instead of "defaultName".

Note that the latest version of the http-client-java emitter no longer use Jackson (hence no @JsonProperty).

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@shikshartin-coder
Comment options

Answer selected by shikshartin-coder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants