LuaTableSerializer 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package LuaTableSerializer --version 1.0.1
                    
NuGet\Install-Package LuaTableSerializer -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="LuaTableSerializer" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LuaTableSerializer" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="LuaTableSerializer" />
                    
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 LuaTableSerializer --version 1.0.1
                    
#r "nuget: LuaTableSerializer, 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 LuaTableSerializer@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=LuaTableSerializer&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=LuaTableSerializer&version=1.0.1
                    
Install as a Cake Tool

Lua Table Serializer

Serialise/Deserialize C# data into a string representing a Lua Table

Example

Code:

using LuaTableSerializer;

var lst = new List<string>(){"Hey", "You"};
var dict = new Dictionary<string, object>{
    {"Bob", 1},
    {"James", 1.1},
    {"Sid", "Sid"},
    {"list", lst},
    {"dict", new Dictionary<string, int>{
        {"1", 1},
        {"2", 2},
        {"3", 3},
        {"4", 4},
        }
    },
    {"dictNumKey", new Dictionary<int, int>{
        {1, 1},
        {2, 2},
        {3, 3},
        {4, 4},
        }
    },
    {"dictOBJ", new Dictionary<string, object>{
        {"1", 1},
        {"1.5", 1.5},
        {"str", "item"},
        {"lst", lst},
        }
    }
};
var serialisedData = LuaSerializer.Serialize(dict);
Console.WriteLine($"mission = {serialisedData}");
var deserialised  =  LuaSerializer.Deserialize(serialisedData);
Utils.PrintDict(deserialised);

Output:

mission = {
        ["Bob"] = 1,
        ["James"] = 1.1,
        ["Sid"] = "Sid",
        ["list"] = {
                [1] = "Hey",
                [2] = "You",
                },
        ["dict"] = {
                ["1"] = 1,
                ["2"] = 2,
                ["3"] = 3,
                ["4"] = 4,
                },
        ["dictNumKey"] = {
                [1] = 1,
                [2] = 2,
                [3] = 3,
                [4] = 4,
                },
        ["dictOBJ"] = {
                ["1"] = 1,
                ["1.5"] = 1.5,
                ["str"] = "item",
                ["lst"] = {
                        [1] = "Hey",
                        [2] = "You",
                        },
                },
        }
// Print Dictionary as data.
K:Bob V:1
K:James V:1.1
K:Sid V:Sid
K:list V:
        K:1 V:Hey
        K:2 V:You
K:dict V:
        K:1 V:1
        K:2 V:2
        K:3 V:3
        K:4 V:4
K:dictNumKey V:
        K:1 V:1
        K:2 V:2
        K:3 V:3
        K:4 V:4
K:dictOBJ V:
        K:1 V:1
        K:1.5 V:1.5
        K:str V:item
        K:lst V:
                K:1 V:Hey
                K:2 V:You

Classes

Classes can support serialization with the function public string ToLuaString() This is just so you can output an class how you want and often incorporates a nested serialization

 public string ToLuaString()
 {
        var obj = newDictionary<string,string>{{"value",value}};
        return LuaSerializer.Serialize(obj);
 }
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.2 1,000 6/24/2025
1.0.1 215 6/24/2025
1.0.1-rc 265 6/24/2025
1.0.0 217 6/24/2025
0.0.3 2,071 1/1/2023
0.0.2 459 9/3/2022