Last active
October 13, 2018 08:52
-
-
Save michael-wolfenden/b590d4020f088d7929f9616ffb389a57 to your computer and use it in GitHub Desktop.
Serialize Left
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using ServiceStack; | |
using ServiceStack.Text; | |
using LanguageExt; | |
using static LanguageExt.Prelude; | |
using Newtonsoft.Json; | |
public class Error : NewType<Error, string> | |
{ | |
public Error(string value) : base(value) { } | |
} | |
var toSerialize = Left<Error, int>(Error.New("some error")); | |
var json = JsonConvert.SerializeObject(toSerialize); | |
var deserialized = JsonConvert.DeserializeObject(json, typeof(Either<Error, int>)); | |
json.PrintDump(); | |
deserialized.PrintDump(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<packages> | |
<package id="ServiceStack.Text" version="5.2.0" targetFramework="net45" /> | |
<package id="LanguageExt.Core" version="3.0.24" targetFramework="net45" /> | |
<package id="System.ValueTuple" version="4.5.0" targetFramework="net45" /> | |
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net45" /> | |
</packages> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment