Tag Archives: Newtonsoft

C# Convert XML to JSON using dynamic ExpandoObject, XDocument and NewtonSoft.JSON

So I receive these XML feeds from my client, but I need to enrich the contents before I can use the data. AND I would like to work with JSON instead. So how to do that with a few lines … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , , , , , , , | Leave a comment

C# Deserialize JSON to dynamic ExpandoObject()

The Microsoft System.Text.Json.Serialization.JsonSerializer cannot (yet) convert JSON into dynamic objects. But good ole Newtonsoft.Json can. The conversion is simple too: After the conversion, you can work with the dynamic object as you wish: MORE TO READ: How to serialize and … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , , , | 1 Comment

Azure.Storage.Queues QueueMessage Deserialize JSON with .NET Core

The documentation around .NET QueueMessage is a little fuzzy so depending on the version of your NuGet libraries might differ in properties. This article uses the Azure.Storage.Queues, Version=12.7.0.0. If you, like me, have systems writing JSON messages to the queue, … Continue reading

Posted in .net, .NET Core, c#, General .NET, Microsoft Azure | Tagged , , , , , | 1 Comment

C# Newtonsoft camelCasing the serialized JSON output

JSON love to be camelCased, while the C# Model class hates it. This comes down to coding style, which is – among developers – taken more seriously than politics and religion. But fear not, with Newtonsoft (or is it newtonSoft … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , , , , | Leave a comment

C# HttpClient POST or PUT Json with content type application/json

The HttpClient is a nifty tool for getting and sending data to a URL, but it works differently from the old fashioned WebRequest class. The content type is added to the post data instead of added as a header parameter. … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , , | 4 Comments

C# Newtonsoft serialize property that is an array and a string

IdentityServer4 has a strange way of returning roles. If there is only one role, the property is a string: But if there is more than one role, the property is an array of strings: If the property is a string, … Continue reading

Posted in .net, .NET Core, c#, General .NET | Tagged , , | 2 Comments

C# Using Newtonsoft and dynamic ExpandoObject to convert one Json to another

The scenario where you convert one input Json format to another output Json is not uncommon. Before C# dynamic and ExpandoObject you would serialize the input Json to POCO model classes and use a Factory class to convert to another … Continue reading

Posted in c#, General .NET | Tagged , , , | 4 Comments

Azure CloudQueue, Get and Set Json using Newtonsoft.Json and Microsoft.WindowsAzure.Storage

The Microsoft Azure Cloud have a nice simple Queue mechanism in their Azure Storage where you can store up to 64 kb of data for up to 7 days. The queue is very easy to set up and very easy … Continue reading

Posted in .net, c#, General .NET | Tagged , , , , | 4 Comments