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

TOML 规范兼容问题 #2

Open
uioz opened this issue Jun 2, 2021 · 1 comment
Open

TOML 规范兼容问题 #2

uioz opened this issue Jun 2, 2021 · 1 comment

Comments

@uioz
Copy link
Owner

uioz commented Jun 2, 2021

说明

规范地址:

https://toml.io/en/v1.0.0

目前存在的最大问题是 toml 支持对 key 和 table 进行分组:

name = "Orange"
physical.color = "orange"
physical.shape = "round"
site."google.com" = true

结果:

{
  "name": "Orange",
  "physical": {
    "color": "orange",
    "shape": "round"
  },
  "site": {
    "google.com": true
  }
}

webpack.definePlugin 本质是将解析到的 key 替换为对应的 value, 只会解析对象的第一层.

如果我们将转为 JSON 的结构进行遍历, 将无法解决值为键值对的问题, 因为无法进行区分对象到底是否值还是用作键.

physical.color = {type = 'a'}
physical.shape = {mode = 'b'}

目前暂定的是不对 toml 的点号连接符语法做支持, 用户可以这样编写, 但是得到的结果是错误的.

@uioz uioz changed the title TOML 规范兼容 TOML 规范兼容问题 Jun 2, 2021
@LongTengDao
Copy link

实现库倒是可以提供一个API,类似isInlineTable,用于检测是不是内联表

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

2 participants