Skip to content

Instantly share code, notes, and snippets.

@mythz
Created April 23, 2019 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mythz/abbbb0e707e910e6379703edd442d2db to your computer and use it in GitHub Desktop.
Save mythz/abbbb0e707e910e6379703edd442d2db to your computer and use it in GitHub Desktop.
Test string DeSerilizeFn
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
JsConfig<string>.DeSerializeFn = str => str?.Trim();
public class Test
{
public string Name { get; set; }
public string Age { get; set; }
public string Description { get; set; }
}
var dto = new Test { Name = " John Doe ", Age = "18" };
var json = dto.ToJson();
var fromDto = json.FromJson<Test>();
var isDescriptionNull = fromDto.Description == null;
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Memory" version="4.5.2" targetFramework="net45" />
<package id="ServiceStack.Text" version="5.5.0" targetFramework="net45" />
<package id="ServiceStack.Client" version="5.5.0" targetFramework="net45" />
<package id="ServiceStack.Interfaces" version="5.5.0" targetFramework="net45" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment