LuaTableSerializer 1.0.2
dotnet add package LuaTableSerializer --version 1.0.2
NuGet\Install-Package LuaTableSerializer -Version 1.0.2
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.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LuaTableSerializer" Version="1.0.2" />
<PackageReference Include="LuaTableSerializer" />
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.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: LuaTableSerializer, 1.0.2"
#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.2
#: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.2
#tool nuget:?package=LuaTableSerializer&version=1.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 | Versions 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.
-
net9.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.