I exported my cookies in a Json file. It looks like this:
[
{
"name": "abc",
"value": "0000",
"domain": ".domain.com",
"hostOnly": false,
"path": "/",
"secure": false,
"httpOnly": false,
"sameSite": "no_restriction",
"session": false,
"firstPartyDomain": "",
"partitionKey": null,
"expirationDate": 1734526188,
"storeId": null
},
{
"name": "dfg",
"value": "777",
"domain": ".domain.it",
"hostOnly": false,
"path": "/",
"secure": true,
"httpOnly": true,
"sameSite": "no_restriction",
"session": false,
"firstPartyDomain": "",
"partitionKey": null,
"expirationDate": 1684947948,
"storeId": null
}
]
As you can see, there are some values which are strings, such as name, hostOnly is a boolean, partitionKey is a nullable and expirationDate is an integer.
This is the C# code I am using
json = File.ReadAllText("json.txt");
JArray array = JArray.Parse(json);
foreach(JObject cookie_json in array)
{
foreach(var entry in cookie_json)
{
cookies.Add(new Cookie(entry.Key, (string?)entry.Value));
}
}
But here I find a couple of errors:
Cookie()constructor accepts only strings asValueand so I am not able to add integers, booleans and not nullable elements, 'cause a nullable will throw an Exception- I am creating a new Cookie for each entry (row) not for each Json element (representing one cookie). How can I fix that?

