.Net JsonSerializer does not serialize tuple's values
09:46 21 Dec 2021

JSON serializer returns an empty JSON object.

using System.Text.Json;

(int, int) tuple1 = (1, 2);
var token = JsonSerializer.Serialize(tuple1); // return empty object {}

(int item1, int item2) tuple2 = (1, 2);
token = JsonSerializer.Serialize(tuple2); // return empty object {}

(int item1, int item2) tuple3 = (item1:1, item2:2);
token = JsonSerializer.Serialize(tuple3); // return empty object {}

it can be passed by many workarounds

I'm trying to understand why or what prevents the serializer to understands the tuples

is it related to the tuples' structure

c# json tuples .net-6.0 system.text.json