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

Modify a HOCON file #391

Open
ahhyeonny opened this issue Mar 27, 2023 · 0 comments
Open

Modify a HOCON file #391

ahhyeonny opened this issue Mar 27, 2023 · 0 comments

Comments

@ahhyeonny
Copy link

ahhyeonny commented Mar 27, 2023

Version Information
Version of Akka.NET?
Which Akka.NET Modules?
Akka 1.5.1

Describe the bug
If you save it as shown above, it will be saved in JSON format as follows:

abc : {
    test : {
      aaa : 2.22.2.1
      abscd : 9131
      aaabbb : on
    }
  }

The desired format is as follows:

abc.test
{
  aaa  =  2.22.2.1
  abscd  =  9131
  aaabbb = on
}

When I modify a HOCON file, I want to save it with the original format and only change the values.

To Reproduce
Steps to reproduce the behavior:

using Akka.Configuration;
using System.IO;

namespace HoconTest
{
    public class Program
    {
        static void Main(string[] args)
        {
            var hocon = @"abc.test
{
  aaa  =  2.22.2.1
  abscd  =  9131
  aaabbb = on
}";
            var config = ConfigurationFactory.ParseString(hocon);
            var hoconPath = "C:\\Workspace\\Test\\test.hocon";

            var logLevel = "DEBUG";
            config = config.WithFallback(ConfigurationFactory.ParseString($"akka.cluster.collector.user = {logLevel}"));

            config = ConfigurationFactory.ParseString($"akka.cluster.collector.user = {logLevel}").WithFallback(config);
            File.WriteAllText(hoconPath, config.Root.ToString());

        }
    }
}

It is a console program simply designed to check the saved file.

Expected behavior
A clear and concise description of what you expected to happen.

Actual behavior
What actually happened and how did it differ from your expectations?

Screenshots
If applicable, add screenshots to help explain your problem.

Environment
Are you running on Linux? Windows? Docker? Which version of .NET?
Windows, .NET Framework 4.7

Additional context
Add any other context about the problem here.

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

1 participant