JSON.NET converter for trimming and removing duplicate spaces in incoming strings.
Add the TrimStringConverter
to your configured JsonSerializerSettings
and it will trim and remove multiple spaces from incoming strings.
namespace Example
{
using System;
using Be.Vlaanderen.Basisregisters.Converters.TrimString;
using Newtonsoft.Json;
public class Test
{
public string Something { get; set; }
}
public class Program
{
public static void Main(string[] _)
{
var json = @"{ ""something"": "" This is stuff some users input "" }";
var s = new JsonSerializerSettings();
s.Converters.Add(new TrimStringConverter());
Console.WriteLine($"'{JsonConvert.DeserializeObject<Test>(json, s).Something}'");
// 'This is stuff some users input'
}
}
}
Running this will result in:
$ dotnet run
'This is stuff some users input'
- .NET Core - MIT
- .NET Core Runtime - CoreCLR is the runtime for .NET Core. It includes the garbage collector, JIT compiler, primitive data types and low-level classes. - MIT
- .NET Core APIs - CoreFX is the foundational class libraries for .NET Core. It includes types for collections, file systems, console, JSON, XML, async and many others. - MIT
- .NET Core SDK - Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI. - MIT
- Roslyn and C# - The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs. - Apache License 2.0
- F# - The F# Compiler, Core Library & Tools - MIT
- F# and .NET Core - F# and .NET Core SDK working together. - MIT
- Paket - A dependency manager for .NET with support for NuGet packages and Git repositories. - MIT
- FAKE - "FAKE - F# Make" is a cross platform build automation system. - MIT
- FluentAssertions - Fluent API for asserting the results of unit tests. - Apache License 2.0
- Newtonsoft.Json - Json.NET is a popular high-performance JSON framework for .NET - MIT
- npm - A package manager for JavaScript. - Artistic License 2.0
- semantic-release - Fully automated version management and package publishing. - MIT
- semantic-release/changelog - Semantic-release plugin to create or update a changelog file. - MIT
- semantic-release/commit-analyzer - Semantic-release plugin to analyze commits with conventional-changelog. - MIT
- semantic-release/exec - Semantic-release plugin to execute custom shell commands. - MIT
- semantic-release/git - Semantic-release plugin to commit release assets to the project's git repository. - MIT
- semantic-release/github - Semantic-release plugin to publish a GitHub release. - MIT
- semantic-release/npm - Semantic-release plugin to publish a npm package. - MIT
- semantic-release/release-notes-generator - Semantic-release plugin to generate changelog content with conventional-changelog. - MIT
- commitlint - Lint commit messages. - MIT
- commitizen/cz-cli - The commitizen command line utility. - MIT
- commitizen/cz-conventional-changelog A commitizen adapter for the angular preset of conventional-changelog. - MIT
- husky - Git hooks made easy. - MIT
- Be.Vlaanderen.Basisregisters.Build.Pipeline - Contains generic files for all Basisregisters Vlaanderen pipelines. - MIT