你说:

我想在 gps 表中设置测量键并且只可变一次而不是在 msgpack 和 json 以及 1 和 2 中冗余

你不这样做是因为 TOML 格式的创建者说:

因为我们需要一种体面的人类可读格式,它可以明确地映射到哈希表,而 YAML 规范长达 80 页,这让我很生气。不,JSON 不算数。你知道为什么。

measurement

您正确的 TOML 文件:

[database]

host = "localhost"

port = 8086

https = true

username = "root"

password = "root"

db = "test"


[cloud]

deviceType = "2be386e9bbae"

deviceId = "119a705fa3b1"

password = "test"

token = "dqpx5vNLLTR34"

endpoint = "mqtts://mqtt1.endpoint.com"


[gps]

[gps.msgpack]

topic = "/evt/gps/msgpack"

measurement = "gps"


[gps.json]

topic = "/evt/gps/json"

measurement = "gps"


[imu]

[imu.1]

measurement = "imu"

tag = "NODE1"

topic = "/evt/imu1/msgpack"

[imu.2]

measurement = "imu"

tag = "NODE2"

topic = "/evt/imu2/msgpack"