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

dotnet连接配置中心通过官方提供的SDK注入后 获取json配置乱码 #242

Closed
zhao-jing-hui opened this issue Apr 18, 2024 · 2 comments

Comments

@zhao-jing-hui
Copy link

1、我已经检查apollo中配置文件json格式是正确的
2、我已经测试官方提供的demo 获取json格式的配置文件也是乱码 https://github.com/ctripcorp/apollo.net/tree/master/Apollo/Logging/Spi
61d11639556df6bd5b9594855632a95f

Copy link

dosubot bot commented Apr 18, 2024

针对您遇到的JSON配置乱码问题,这可能是由于字符编码设置不正确或未被正确应用导致的。在处理Apollo配置时,确保所有请求和响应都强制使用UTF-8编码是非常重要的。在Apollo的Java配置代码中,有一个设置可以强制对所有请求和响应使用UTF-8编码,但这个设置默认可能是被注释掉的。您可以尝试取消注释或检查相关配置,确保编码设置正确应用。

对于Apollo .NET SDK,它默认使用UTF-8编码处理配置。您可以通过ConfigService.GetAppConfig()方法获取配置,并使用config.GetProperty方法来获取特定键的配置值。这样可以确保您获取的配置值是按照预期的编码进行处理的。

如果调整编码设置后问题仍然存在,建议检查您使用的Apollo .NET SDK版本,并提供更详细的信息,以便进一步分析和解决问题。

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@nobodyiam nobodyiam transferred this issue from apolloconfig/apollo Apr 20, 2024
@nobodyiam
Copy link
Member

nobodyiam commented Apr 20, 2024

duplicated with #240

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