ToonNetLib 1.0.1

dotnet add package ToonNetLib --version 1.0.1
                    
NuGet\Install-Package ToonNetLib -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ToonNetLib" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ToonNetLib" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ToonNetLib" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ToonNetLib --version 1.0.1
                    
#r "nuget: ToonNetLib, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ToonNetLib@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ToonNetLib&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ToonNetLib&version=1.0.1
                    
Install as a Cake Tool

ToonNet

EN: Token-Oriented Object Notation (TOON) — a lightweight, efficient notation for serializing and deserializing objects, optimized for AI API integrations.
PT: Notação de Objetos Orientada a Tokens (TOON) — uma notação leve e eficiente para serialização e desserialização de objetos, otimizada para integrações com APIs de IA.

NuGet License: MIT .NET


ToonNet Logo

Overview / Visão Geral

EN:
ToonNet is a .NET Standard 2.0 library that implements TOON (Token-Oriented Object Notation) — a compact textual representation of structured data, designed to reduce token cost in AI API interactions.

PT:
ToonNet é uma biblioteca .NET Standard 2.0 que implementa o formato TOON (Token-Oriented Object Notation), uma representação textual compacta de dados estruturados, criada para reduzir o custo de tokens em interações com APIs de IA.


Installation / Instalação

dotnet add package ToonNet

Usage / Uso

Below are examples showing how to serialize and deserialize objects using ToonNet.
Abaixo estão exemplos mostrando como serializar e desserializar objetos usando o ToonNet.


1. Serialize using ToonDocument / Serializar com ToonDocument

using ToonNet.Models;

var doc = new ToonDocument
{
    RootName = "users",
    Fields = new List<string> { "Id", "Name", "Role" },
    Rows = new List<string[]>
    {
        new[] { "1", "Alice", "admin" },
        new[] { "2", "Bob", "user" }
    }
};

string toon = doc.ToString();
Console.WriteLine(toon);

Output / Saída:

users[2]{Id,Name,Role}:
  1,Alice,admin
  2,Bob,user

2. Deserialize from TOON text / Desserializar de texto TOON

var toonText = @"users[2]{Id,Name,Role}:
  1,Alice,admin
  2,Bob,user";

var document = ToonDocument.Parse(toonText);

Console.WriteLine(document.RootName); // "users"
Console.WriteLine(document.Fields[1]); // "Name"
Console.WriteLine(document.Rows[0][2]); // "admin"

EN: Converts back into a structured ToonDocument.
PT: Converte novamente em um ToonDocument estruturado.


3. Serialize objects using ToonSerializer / Serializar objetos com ToonSerializer

using ToonNet.Serialization;

var users = new List<User>
{
    new User { Id = 1, Name = "Alice", Role = "admin" },
    new User { Id = 2, Name = "Bob", Role = "user" }
};

string toon = ToonSerializer.Serialize(users, "users");

Console.WriteLine(toon);

Output / Saída:

users[2]{Id,Name,Role}:
  1,Alice,admin
  2,Bob,user

4. Deserialize TOON text using ToonDeserializer / Desserializar texto TOON com ToonDeserializer

using ToonNet.Serialization;

var toonText = @"users[2]{Id,Name,Role}:
  1,Alice,admin
  2,Bob,user";

var users = ToonDeserializer.Deserialize<User>(toonText);

Console.WriteLine(users[0].Name); // "Alice"
Console.WriteLine(users[1].Role); // "user"

public class User
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Role { get; set; }
}

EN: Converts TOON text directly into a list of typed objects.
PT: Converte o texto TOON diretamente em uma lista de objetos tipados.


Tests / Testes

EN: ToonNet uses xUnit, FluentAssertions, and Bogus for unit testing.
PT: ToonNet utiliza xUnit, FluentAssertions e Bogus para testes unitários.

dotnet test

Motivation / Motivação

EN:
AI APIs often charge by token usage. TOON reduces textual noise while preserving semantic meaning, providing a token-efficient way to represent structured data.

PT:
APIs de IA geralmente cobram por uso de tokens. TOON reduz o ruído textual preservando o significado semântico, oferecendo uma forma eficiente de representar dados estruturados.


Contributing / Contribuindo

EN:
Contributions are welcome! Fork the repository, create a new branch, commit your changes, and open a pull request.

PT:
Contribuições são bem-vindas! Faça um fork do repositório, crie uma nova branch, envie suas alterações e abra um pull request.


License / Licença

MIT License — see the LICENSE file for details.
Licenciado sob MIT — consulte o arquivo LICENSE para mais detalhes.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 360 11/13/2025
1.0.0 314 11/13/2025