Skip to content

Invoice JSON deserialization error #31

@gradientskier

Description

@gradientskier

Dear BTCPay team,

I am using NBitpayClient 1.0.0.39:

<PackageReference Include="NBitpayClient" Version="1.0.0.39" />

I am trying to serialize and deserialize in JSON the invoice structure using System.Text.Json, where MyBTCPay is an instance of NBitpayClient.Bitpay:

using System.Text.Json;

var satsAmount = 100000;
var invoice = await MyBTCPay.CreateInvoiceAsync(new NBitpayClient.Invoice(satsAmount, "SATS"));
var jsonString = JsonSerializer.Serialize(invoice);
var invoice2 = JsonSerializer.Deserialize<NBitpayClient.Invoice>(jsonString);

But when I try to deserialize the jsonString into invoice2, I get the following error:

---> System.NotSupportedException: Deserialization of reference types without parameterless constructor is not supported. Type 'NBitcoin.Money'

Do you have any suggestion about how I can properly serialize/deserialize a NBitpayClinet Invoice in JSON?

Many thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions