Skip to content

Conversation

Danieladu
Copy link
Contributor

@Danieladu Danieladu commented Aug 17, 2020

Fixes #4462

Description

Change JSON serialization formatting from Formatting.Indented to Formatting.None .

Results

Remove the indention from the JSON body to shrink the size of HTTP request.

Local test result: With code:

            var serializerSettings = new JsonSerializerSettings
            {
                DateFormatHandling = DateFormatHandling.IsoDateFormat,
                DateTimeZoneHandling = DateTimeZoneHandling.Utc,
                NullValueHandling = NullValueHandling.Ignore,
                ReferenceLoopHandling = ReferenceLoopHandling.Serialize
            };

            var jObj = new JObject
            {
                ["key1"] = "value1",
                ["key2"] = "value2"
            };

            serializerSettings.Formatting = Formatting.None;
            Console.WriteLine("Serialization result with None formatting:");
            Console.WriteLine(JsonConvert.SerializeObject(jObj, serializerSettings));

            serializerSettings.Formatting = Formatting.Indented;
            Console.WriteLine("\r\nSerialization result with Indented formatting:");
            Console.WriteLine(JsonConvert.SerializeObject(jObj, serializerSettings));

Result screenshot:
image

@mrivera-ms mrivera-ms changed the base branch from master to main August 20, 2020 21:48
@Danieladu
Copy link
Contributor Author

@johnataylor @carlosscastro @mrivera-ms could this ready to merge?

@mrivera-ms mrivera-ms merged commit 02c4a13 into main Sep 10, 2020
@mrivera-ms mrivera-ms deleted the hond/fix-json-format branch September 10, 2020 17:15
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.

DCR: remove indention from serialized activities sent by BotFrameworkAdapter

4 participants