Cannot Json Deserialize struct System.Numerics.BigInteger

I am using BigInteger and now want to persist some POCOs to Redis.

When trying to deserialize, I found that ServiceStack is unable using it’s default Struct.Parse(string) signature:

System.Numerics.BigInteger x = 100;
var y = System.Numerics.BigInteger.Parse("100");
var json = x.ToJson();
var z = json.FromJson<System.Numerics.BigInteger>(); // <<- Throws 'Cannot bind to the target method because its signature is not compatible with that of the delegate type'

I have not be able to add a custom Deserialize like I normally would for something like MongoDB.

Where should I provide the Func to deserialize the JsonProperty into a BigInteger? Literally just requires a call to the static struct Parse method.

Intended use:
MarketEdge? edge = _redis.Get<MarketEdge>(edgeKey);

MarketEdge contains two BigInteger properties

Many thanks.

Doh - found it, sorry for the waste of time.

JsConfig<BigInteger>.SerializeFn = x => x.ToString();
JsConfig<BigInteger>.DeSerializeFn = x => BigInteger.Parse(x);
2 Likes