我的应用程序正在加载和分析一个嵌套的 YAML 文件,使用 RepresentationModel 提取每个键/值对。一些值将被更改,然后我写回 YAML 文件。输入文件为:
account:
menu:
dev: "Device Settings" # Item comment 1
port: "Portal Accounts"
prof: "Personal Information"
ports:
# Comment line
desc: "Below is a list of available portals. You can use the sections below to manage each portal account."
det: "Manage Accounts"
no_enabled: "No portals are currently enabled."
ti: "Account Access"
pro:
ti: Information
但输出文件看起来像
account:
menu:
dev: Device Settings changed
port: Portal Accounts changed
prof: Personal Information changed
ports:
desc: Below is a list of available portals. You can use the sections below to manage each portal account. changed
det: Manage Accounts changed
no_enabled: No portals are currently enabled.
&1735269872 ti: Account Access
pro:
ti: Information
- 使用 Yaml.Save() 时如何保留输入文件中的双引号?
- 这个奇怪的数字 &1735269872 是什么以及如何防止它在保存 YAML 时被写入?在较长的文件中,其他数字出现在不同的位置。
- 是否可以在浏览 YAML 时保留评论,甚至更好地访问它们?