SkillAgentSearch skills...

TupleAsJsonArray

Convert C# Tuple to/from JSON Array

Install / Use

/learn @arogozine/TupleAsJsonArray
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

TupleAsJsonArray

Convert C# Tuple to/from JSON Array

Nuget Nuget

About

  1. Serialize Tuple and ValueTuples to JSON Array
  2. Deserialize JSON Arrays as Tuples and ValueTuples
  3. Bridges the gap between JS Destructuring assignment and C# ValueTuples.

Using

.NET C#

// 1. Import Library
using TupleAsJsonArray;

// 2. Set Up Json Serializer Options
var options = new JsonSerializerOptions
{
    Converters =
    {
        new TupleConverterFactory(),
    }
};

// 3. Serialize Tuples to Array
var jsonArray = JsonSerializer.Serialize((1, 2, 3, 4), options);

// 4. Deserialize Arrays to Tuples
var (a, b, c, d) = JsonSerializer.Deserialize<(int, int, int, int)>("[1, 2, 3, 4]", options);

JavaScript

// Tuples in Models will now show up as arrays
// that you can destructure
const [a, b, c, d] = modelFromServer.TupleParam;
View on GitHub
GitHub Stars14
CategoryDevelopment
Updated6mo ago
Forks4

Languages

C#

Security Score

87/100

Audited on Oct 9, 2025

No findings