项目作者: Informatievlaanderen

项目描述 :
JSON.NET converter for trimming and removing duplicate spaces in strings.
高级语言: C#
项目地址: git://github.com/Informatievlaanderen/trim-string-jsonconverter.git
创建时间: 2018-12-15T22:08:45Z
项目社区:https://github.com/Informatievlaanderen/trim-string-jsonconverter

开源协议:MIT License

下载


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.

  1. namespace Example
  2. {
  3. using System;
  4. using Be.Vlaanderen.Basisregisters.Converters.TrimString;
  5. using Newtonsoft.Json;
  6. public class Test
  7. {
  8. public string Something { get; set; }
  9. }
  10. public class Program
  11. {
  12. public static void Main(string[] _)
  13. {
  14. var json = @"{ ""something"": "" This is stuff some users input "" }";
  15. var s = new JsonSerializerSettings();
  16. s.Converters.Add(new TrimStringConverter());
  17. Console.WriteLine($"'{JsonConvert.DeserializeObject<Test>(json, s).Something}'");
  18. // 'This is stuff some users input'
  19. }
  20. }
  21. }

Running this will result in:

  1. $ dotnet run
  2. '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