Skip to content

Modify a HOCON file #391

@ahhyeonny

Description

@ahhyeonny

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions