microsoft / botbuilder-java

The Microsoft Bot Framework provides what you need to build and connect intelligent bots that interact naturally wherever your users are talking, from text/sms to Skype, Slack, Office 365 mail and other popular services.
http://botframework.com
MIT License
178 stars 115 forks source link

Ignore fields to avoid duplicating values when serializing #1475

Closed esfomeado closed 1 year ago

esfomeado commented 2 years ago

Description

When deserializing an Activity , teamsActivity and fromStreamingConnection are created due to the method name.

If we then serialize and deserialize it again we will end up with two properties named teamsActivity and fromStreamingConnection. This can created a few issues because it will have duplicate keys when deserialized so it's no longer a valid JSON.

Specific Changes

Testing

        ObjectMapper mapper = new ObjectMapper().registerModule(new JavaTimeModule());
        Activity activity1 = new Activity();
        String json1 = mapper.writeValueAsString(activity1);
        Activity activity2 = mapper.readValue(json1, Activity.class);
        String json2 = mapper.writeValueAsString(activity2);