De Serialise Json Object to pass to JS function Interop from Blazor

I am using Blazor WASM and am wanting to accept payments using a JS drop-in from Adyen.
I have actually managed to make it work, see this question: My previous question

But to some extent I don’t understand why?.

A (what looks like good JSON) response comes back from the server. This was copied from the browser debug windown into a VSCode file and formatted:

{
"channel": 3,
"recurringProcessingModel": null,
"shopperInteraction": null,
"accountInfo": null,
"additionalAmount": null,
"additionalData": null,
"allowedPaymentMethods": null,
"amount": {
    "currency": "GBP",
    "value": 300
},
"applicationInfo": null,
"authenticationData": null,
"billingAddress": null,
"blockedPaymentMethods": null,
"captureDelayHours": null,
"company": null,
"countryCode": "GB",
"dateOfBirth": null,
"deliverAt": null,
"deliveryAddress": null,
"enableOneClick": null,
"enablePayOut": null,
"enableRecurring": null,
"expiresAt": "2023-04-17T11:28:00+01:00",
"id": "CS2387F156F0520AB5",
"lineItems": [
    {
        "amountExcludingTax": 0,
        "amountIncludingTax": 300,
        "description": "Site Credit",
        "id": null,
        "imageUrl": null,
        "itemCategory": null,
        "productUrl": null,
        "quantity": 1,
        "taxAmount": 0,
        "taxPercentage": 0
    }
],
"mandate": null,
"mcc": null,
"merchantAccount": "xxxxxxxxxxxxxxxx",
"merchantOrderReference": null,
"metadata": null,
"mpiData": null,
"recurringExpiry": null,
"recurringFrequency": null,
"redirectFromIssuerMethod": null,
"redirectToIssuerMethod": null,
"reference": "000000276",
"returnUrl": "yyyyyyyyyyyyyyyyyyyyyyyyyy",
"riskData": null,
"sessionData": "Ab02b4c0!BQABAgCZiH8XQ1HvzCtIGU56spUsUSSi6w21FzE3cIeiuAV6mQApaanuRgK2bg00m0NAwz53ZEyQbjHbuV1o7SF4BT5R2DqE1J4EM4Qm+Ma7MU5r+xg21ovnetvBzZpd3iGVH0mykv0uVLCD2bEP1oKgVqLnMuNxkYaSZtJYbMvo/fm4rCl1lJbL2A0AMcJPXXvk0rUZmVj1UaPgjjW9WW0mS1mur53RDEjh/ZFT1YaWTz9oKXh8Rf91xUJcQW6FNjVLjkto4UGNx718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HzmjjBaox4luOUhnJxSkKSAmDdV5d40MgCkPkjsVmqBCPWG0Elutlw2EQSsr/P+HEoOUTrU4BQDkJlyXTpPn7RYEmXfQ+w3ueAwAgY5BlVCsyw00HgCbmacpe2KKfj8TJAI24wUF1XY9seKsQn3Z5TzVgPZm0lGV9Ju8IzOt2qf97iB20LfTTg4it0/Es4+yl9HK4mNEvfean1tEQPxDfO+Elhq69lygul4x1RKFINMnDtL5ejQ0hU=",
"shopperEmail": null,
"shopperIP": null,
"shopperLocale": "en-US",
"shopperName": null,
"shopperReference": null,
"shopperStatement": null,
"socialSecurityNumber": null,
"splitCardFundingSources": false,
"splits": null,
"store": null,
"storePaymentMethod": null,
"telephoneNumber": null,
"threeDSAuthenticationOnly": false,
"trustedShopper": null
}

From the previous question, I was desrialising this as ASCII and passing it in to my JS interop code as follows:

    ...
    Stream? jsonresponse = await response.Content.ReadAsStreamAsync();
    string res;
    using (var reader = new StreamReader(jsonresponse, Encoding.ASCII))
    {
        res = reader.ReadToEnd();
    }
    return res;

The calling function does this: (AdyenSession is a string, ObjRef is to allow the JS to callback)

    AdyenSession = await _transactionService.GetAdyenPaymentSessionAsync(_userService.CurrentUser.Id, amount);
    objRef = DotNetObjectReference.Create(this);
    await _JS.InvokeVoidAsync("setAdyenCheckoutConfiguration", AdyenSession, _transactionService.AdyenPublicClientKey, objRef);

For completeness, the JavaScript code starts with this:

var AdyenJsonObject;
var RawAdyenJsonObject;
var checkout;
var dropinComponent;

async function setAdyenCheckoutConfiguration(AdyenSessionResponse, passedKey, dotnethelper) {

console.log(AdyenSessionResponse);
RawAdyenJsonObject = AdyenSessionResponse;
AdyenJsonObject = JSON.parse(AdyenSessionResponse);
...

When I break at the JSON.parse line above, the value (again formatted in VSCode) is:

{
"environment": "test",
"clientKey": "test_AGQHLB7CRNA3BMHWPBIUOBNI4QZGVK6F",
"analytics": {
    "enabled": true
},
"session": {
    "id": "CS55FA4A6E3BD028CB",
    "sessionData": "Ab02b4c0!BQABAgAM99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Wck1FR/3GCKg5lXIOICfgCxsTfgDPMqmYXUCSxP582oma2bfblq7scELXHlbe8yDk6EndHS9rJXrLQHQ59UzYnqCEyh/sfKM8Q1IfyWC9Do1s16ZXjl32kRVnTtRPMBulaChTNOTqxvF8ECpuNfcypLziBBxFk4ki3K+qRk9HI4edMx2APXhUwu1d2ihJKh7gKDYu+LagJRjoQlEvWTKWNvJoHxuGR0DXueAsrPF3bTcv3259lUr04S6dpIudSYl/rjhcZhf7KrQ68laHOLImCcmnNvp+qJLz2sD5SbwCe6Y+Mu4yGSMYa6kDcLyn38kj7kwSljZLdaFYkMSbM2cber8sB4R/Zhy9MreOaxwmayFMU/+OH+daScyA9IkliLLkAvW/Xf7TuyD1WmkqP0MSv0P4YAarsNleN1zmLldTMLelYO/PcuJlU9hg0P3popX26GoqcZH/1EqROP80qpa4sU27NRfp8uftJHiDpRBm6N3rs7vJ4pCBTYjVzKRg=="
},
"paymentMethodsConfiguration": {
    "card": {
        "hasHolderName": true,
        "holderNameRequired": true,
        "billingAddressRequired": false
    }
}

}

Which again looks like good json, except a lot of it is missing.

The input string to this looks like this:

'{
"channel": 3,
"recurringProcessingModel": null,
"shopperInteraction": null,
"accountInfo": null,
"additionalAmount": null,
"additionalData": null,
"allowedPaymentMethods": null,
"amount": {
    "currency": "GBP",
    "value": 300
},
"applicationInfo": null,
"authenticationData": null,
"billingAddress": null,
"blockedPaymentMethods": null,
"captureDelayHours": null,
"company": null,
"countryCode": "GB",
"dateOfBirth": null,
"deliverAt": null,
"deliveryAddress": null,
"enableOneClick": null,
"enablePayOut": null,
"enableRecurring": null,
"expiresAt"…/ToM4g9D/DcEDzm6xqKEzNVIMPmWtFtaXILQlOsn1q9LNSojuJYXTVxv12hfNb/s0yYDae3YXzS7et5rdLYvzS5aeeCUsj+Yajy3x9+f/OwqKLpqXVGIOkQ4hijH85jusgxxbW35yaWgHQfEjOdbtTX200VlvbsajGSdLKEMWtLcTHtb","shopperEmail":null,"shopperIP":null,"shopperLocale":"en-US","shopperName":null,"shopperReference":null,"shopperStatement":null,"socialSecurityNumber":null,"splitCardFundingSources":false,"splits":null,"store":null,"storePaymentMethod":null,"telephoneNumber":null,"threeDSAuthenticationOnly":false,"trustedShopper":null}'

If I look at the ‘expiresAt’ field it doesn’t look particularly out of the ordinary does it?
From the raw data above…

"enableRecurring": null,
"expiresAt": "2023-04-17T11:28:00+01:00",
"id": "CS2387F156F0520AB5",

Something odd is deffinitely going on, or just that I don’t understand.

Other things I have tried:
Reading as a byte[] array:

    byte[]? arrayres = await response.Content.ReadAsByteArrayAsync();

This reads the array, but again when I try to decode it into ascii or utf-8 string it I get the same result (breaking at expiresAt – or the JSON.parse just barfs…)

I also tried using c# JsonNode object but again a similar problem.

In an Ideal world the Adyen.Model.Checkout c# object ‘CreateCheckoutSessionResponse’ would just read back from the response, but it doesn’t.

Ideas anyone?
Thanks in advance.