Skip to content

Informatievlaanderen/trim-string-jsonconverter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Be.Vlaanderen.Basisregisters.Converters.TrimString Build Status

Goal

JSON.NET converter for trimming and removing duplicate spaces in incoming strings.

Usage

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'

License

MIT License

Credits

Languages & Frameworks

  • .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

Libraries

Tooling

Flemish Government Libraries

About

JSON.NET converter for trimming and removing duplicate spaces in strings.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 9