C# – Case sensitivity in JSON deserialization

By default Newtonsoft does case insensitive JSON deserialization and System.Text.Json does case sensitive JSON deserialization. Case sensitivity comes into play when a JSON string is being deserialized into an object. If you’re using case sensitive deserialization, then keys in the JSON string must match type names exactly, otherwise it won’t deserialize the class/property with the … Read more C# – Case sensitivity in JSON deserialization

System.Text.Json can’t serialize Dictionary unless it has a string key

The built-in JSON serializer in .NET Core can’t handle serializing a dictionary unless it has a string key. When I run this code I get the following exception: System.NotSupportedException: The collection type ‘System.Collections.Generic.Dictionary`2[System.Int32,System.String]’ is not supported. It can only serialize dictionaries with string keys. This is bizarre, and another reason to stick with Newtonsoft for … Read more System.Text.Json can’t serialize Dictionary unless it has a string key

C# – Deserialize JSON to dynamic object

If you want to deserialize JSON without having to create a bunch of classes, use Newtonsoft.Json like this: Now you can use this object like any other object. Example Add the Newtonsoft.Json reference Code Output: JSON Dynamic vs ExpandoObject If you specify <dynamic> instead of <ExpandoObject> it’ll create a JObject. In older versions of Newtonsoft, … Read more C# – Deserialize JSON to dynamic object

Export Trello board and extract the card names and links using C#

I have a Trello board with tons of cards, most of them archived, and I want to go through all of them and determine which ones are worth documenting. In order to that I need to export the board as JSON and extract out the relevant data for each card – which for me is … Read more Export Trello board and extract the card names and links using C#