alexbeletsky / toml-js

TOML parser implementation (node.js + browser)
23 stars 9 forks source link

Angled bracket gets parsed into property name #6

Open stjepanmamusa opened 3 years ago

stjepanmamusa commented 3 years ago

Hi, I'm working (that is trying to create a config generator for Telegraf and it uses a config file in TOML format. I tried your example for parsing the TOML file and it works perfectly, but there is an issue where some properties have angled brackets parsed into their names. Example is on picture bellow.

image

The code I used for this is :

    <script>
        $.get('nru_autogen_conf.conf', function (data) {
            var config = toml.parse(data);

            Object.keys(config).forEach((prop) => console.log(prop));
            console.log(config["[inputs"])
        });
    </script>

Which just outputs all config properties. Am I using this parser in a wrong way or is this unpredicted behavior? I would use the parser as to read the users Telegraf configuration and use the dumper to update it.

Here is a TOML file I'm using :

# Configuration for telegraf agent
[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = ""
  debug = false
  quiet = false
  logfile = ""
  hostname = ""
  omit_hostname = false
[[outputs.influxdb_v2]] 
  urls = ["http://ip:port"]
  token = "$INFLUX_TOKEN"
  organization = "rsta"
  bucket = "rsta_blocks"
[[inputs.cpu]]
  percpu = true
  totalcpu = true
  collect_cpu_time = false
  report_active = false
[[inputs.disk]]
  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
[[inputs.mem]]
[[inputs.net]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]

If more info is needed feel free to request it 😄

jesseditson commented 1 month ago

Seems possible/probable that this is actually the same issue as https://github.com/alexbeletsky/toml-js/issues/4