Skip to content

Instantly share code, notes, and snippets.

@mythz
Created May 14, 2020 17:57
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/e4ea5983fe82c433ddf71d95e650b59e to your computer and use it in GitHub Desktop.
Save mythz/e4ea5983fe82c433ddf71d95e650b59e to your computer and use it in GitHub Desktop.
Using custom Guid in JSON
using System;
using System.Linq;
using ServiceStack;
using ServiceStack.Text;
JsConfig<Guid>.SerializeFn = guid => guid.ToString();
public partial class Dto
{
public Guid Guid { get; set; } = Guid.NewGuid();
}
var dto = new Dto {};
var json = dto.ToJson();
json.Print();
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="System.Memory" version="4.5.3" targetFramework="net45" />
<package id="ServiceStack.Text" version="5.8.0" targetFramework="net45" />
<package id="ServiceStack.Client" version="5.8.0" targetFramework="net45" />
<package id="ServiceStack.Interfaces" version="5.8.0" targetFramework="net45" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment