botbuilder-java icon indicating copy to clipboard operation
botbuilder-java copied to clipboard

Ignore fields to avoid duplicating values when serializing

Open esfomeado opened this issue 3 years ago • 0 comments

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

  • Added @JsonIgnore to the isFromStreamingConnection and isTeamsActivity methods

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);

esfomeado avatar Jun 23 '22 17:06 esfomeado