Tag Archives: JSON

ASP.Net Core API – “‘s’ is an invalid start of a value. Path: $ | LineNumber: 0 | BytePositionInLine: 0.”

If you create an ASP.Net Core API Controller, and you wish to create an endpoint that can accept any string, you would expect this to be correct: But this endpoint will only accept strings in quotes, so posting string will … Continue reading

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

.NET Core MVC Web API – control DateTime format in JSON output using JsonSerializerOptions

When creating API’s with .NET Core MVC, you can control the JSON output by adding JsonOptions to the controllers: This will ensure that when requesting application/json from a GET method, the format returned is JSON. You can then add Converters … Continue reading

Posted in .net, .NET Core, c# | Tagged , , , , | 1 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 , , , | Leave a comment

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 , , | Leave a comment

Deserialize XML array to string[] and how to allow JSON to be deserialized into the same POCO class

How do you deserialize the classic XML array to an string[] type? The XML representation of an array is a list of elements: And the MyArray would normally be deserialized to an annoying class: The solution is to use the … Continue reading

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

Creating dynamic arrays and lists using Dynamic and ExpandoObject in C#

In this previous post, C# Using Newtonsoft and dynamic ExpandoObject to convert one Json to another, I described how you can use the dynamic keyword and the ExpandoObject class to quickly transform JSON without the need for any concrete implementations of … Continue reading

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

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 , , , | 1 Comment

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

.NET DateTime to JSON UNIX JavaScript datetime

When posting datetimes to web services or REST services, you might need to convert the standard .NET DateTime to a UNIX format. Please note than neither REST, nor JavaScript has its own DateTime format. But some systems based on REST … Continue reading

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