Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use As.EXISTING_PROPERTY not to generate JSON with duplicate keys #836

Merged
merged 3 commits into from
Sep 21, 2022

Conversation

Yang-33
Copy link
Contributor

@Yang-33 Yang-33 commented Sep 20, 2022

Hi,

We found com.linecorp.bot.model.narrowcast.recipient generated JSON with duplicate keys.
For example, audience class is serialized like below.

{
    "type":"audience",
    "audienceGroupId": 123,
    "type":"audience"
}

FasterXML/jackson-databind#528 reported this. The audience class has type filed and generates duplicate "type": "audience" if this class doesn't have @JsonTypeInfo(include = JsonTypeInfo.As.EXISTING_PROPERTY).
Other models don't have type filed, so it's enough to add this config to only this class.

About JSON format, https://www.rfc-editor.org/rfc/rfc7159#section-4 says

... The names within an object SHOULD be unique. ...

So this change follows JSON format the RFC defines.

Thanks!

@tokuhirom tokuhirom merged commit b9a851c into line:master Sep 21, 2022
@tokuhirom
Copy link
Member

Good catch, thanks!

@Yang-33 Yang-33 deleted the duplicate-json-field branch October 14, 2022 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants