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
Item1
,Item2
etc. – PresidentTuple<int,int>
with the propertiesItem1
andItem2
– BregenzTuple<int,int>
is a referencey type with properties.(int,int)
is a ValueTuple, a struct with fields. Serializers work with properties by default because fields are typically implementation details – President