Skip to content

Conversation

@huyunan
Copy link

@huyunan huyunan commented Jul 8, 2025

现在我有一个情况是,我用 nconf 生成一个配置文件 config.json ,然后使用监听方法监听 config.json 的变化,重新生成配置。但是用户可能为了方便直接清空文件内容,而不是保留 "{}" 最外层大括号。但这就会有 parse 为空报错问题,所以加了个空判断,如果文件已经生成了,但是文件内容为空,默认设置为空对象。可以吗?
Now I have a situation where I generate a configuration file named config.json using nconf, and then use the listening method to listen for changes in config.json and regenerate the configuration. However, users may directly clear the file content for convenience instead of keeping the outermost curly braces of "{}". However, this would lead to an error when parse is empty. Therefore, an empty judgment was added. If the file has been generated but its content is empty, the default setting is an empty object. Is it okay?
#411

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

Successfully merging this pull request may close these issues.

1 participant