Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dotted keys serialized with quotes, spurious empty lines in output #40

Closed
levicki opened this issue Mar 14, 2024 · 2 comments
Closed

Dotted keys serialized with quotes, spurious empty lines in output #40

levicki opened this issue Mar 14, 2024 · 2 comments

Comments

@levicki
Copy link

levicki commented Mar 14, 2024

With the following code:

	public class Pest
	{
		public string Name { get; set; }
		public string Description { get; set; }
	}

	public class Pet
	{
		public string Name { get; set; }
		public string Description { get; set; }
		public List<Pest> Pests { get; set; }
	}

	public class Inhabitant
	{
		public string Name { get; set; }
		public string Description { get; set; }
		public List<Pet> Pets { get; set; }
	}

	public class Planet
	{
		public string Name { get; set; }
		public List<Inhabitant> Inhabitants { get; set; }
	}

	public class Galaxy
	{
		public List<Planet> Planets { get; set; }
	}

	internal class Program
	{
		static void Main(string[] args)
		{
			Galaxy MilkyWay = new Galaxy();

			MilkyWay.Planets = new List<Planet>();

			Planet Earth = new Planet();

			Earth.Name = "Earth";
			Earth.Inhabitants = new List<Inhabitant>();

			Inhabitant Mammals = new Inhabitant();
			Mammals.Name = "Humans";
			Mammals.Description = "xyz";
			Mammals.Pets = new List<Pet>();

			Pest Flea = new Pest();
			Flea.Name = "Fleas";
			Flea.Description = "abc";

			Pet Dogs = new Pet();
			Dogs.Name = "Dogs";
			Dogs.Description = "xyzzy";
			Dogs.Pests = new List<Pest>();
			Dogs.Pests.Add(Flea);

			Pet Cats = new Pet();
			Cats.Name = "Cats";
			Cats.Description = "xyzzy";
			Cats.Pests = new List<Pest>();
			Cats.Pests.Add(Flea);
			
			Mammals.Pets.Add(Dogs);
			Mammals.Pets.Add(Cats);

			Earth.Inhabitants.Add(Mammals);

			MilkyWay.Planets.Add(Earth);

			Planet Mars = new Planet();

			Mars.Name = "Mars";
			Mars.Inhabitants = new List<Inhabitant>();

			Inhabitant GrayOnes = new Inhabitant();

			GrayOnes.Name = "Little Gray Men";
			GrayOnes.Description = "xyz";
			GrayOnes.Pets = new List<Pet>();

			Pet MartianBrainSlug = new Pet();
			MartianBrainSlug.Name = "Martian Brain Slug";
			MartianBrainSlug.Description = "xyzzy";

			GrayOnes.Pets.Add(MartianBrainSlug);

			Mars.Inhabitants.Add(GrayOnes);

			MilkyWay.Planets.Add(Mars);

			string TOML = TomletMain.TomlStringFrom(MilkyWay);
		}
	}

The output looks like this:

[[Planets]]
Name = "Earth"

[[Planets.Inhabitants]]
Name = "Humans"
Description = "xyz"

[["Planets.Inhabitants".Pets]]
Name = "Dogs"
Description = "xyzzy"
Pests = [
	{ Name = "Fleas", Description = "abc" },
]

[["Planets.Inhabitants".Pets]]
Name = "Cats"
Description = "xyzzy"
Pests = [
	{ Name = "Fleas", Description = "abc" },
]



[[Planets]]
Name = "Mars"

[[Planets.Inhabitants]]
Name = "Little Gray Men"
Description = "xyz"
Pets = [
	{ Name = "Martian Brain Slug", Description = "xyzzy" },
]


  1. Quotes seem unnecessary (if they are stripped Tomlet successfully deserializes the document).
  2. There seem to be 2 extra blank lines before Mars and 1 after it.
@SamboyCoding
Copy link
Owner

This should be addressed with 5.3.1

@levicki
Copy link
Author

levicki commented Mar 20, 2024

This should be addressed with 5.3.1

Great work, thanks so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants