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

ApolloJSON格式的内容的展示,不应该自动去掉重复的key #5300

Open
bingSea opened this issue Dec 20, 2024 · 2 comments
Open
Labels
bug Categorizes issue or PR as related to a bug. help wanted

Comments

@bingSea
Copy link

bingSea commented Dec 20, 2024

描述bug

本人在使用Apollo1.8.x)作为配置中心时,发现如果配置内容为json格式时,Apollo会自动进行格式化展示,本来是一个很方便的功能,但最近却遇到了一件糟心的事情,因为Apollo展示时,会自动去掉重复的key,但程序实际获取的内容还是带有重复的key,程序一直报错,到Apollo里检查又看不出错误,这对于配置json内容较大时,更不容易查出。

复现

直接添加带有重复keyjson格式内容,点击内容,即可复现,如图:
image

期望

后续修复一下,对于内容展示形式,可以让用户自行选择,比如jsontext等,当不能展示对应格式时,给出相应提示,而不是自行对内容进行格式化,然后悄悄去掉重复的key,让用户排查错误到怀疑人生。

Copy link

dosubot bot commented Dec 20, 2024

Hey @bingSea, I'm here to help you with any bugs, questions, or contributions. Let me know how I can assist you!

Apollo's web interface renders JSON content using a directive called showTextModalDirective. This directive processes JSON content and may remove duplicate keys during rendering. The JSON parsing is handled by the parseBigInt function, which processes the text to handle large integers by replacing them with a specific format before parsing [1].

To address the issue of duplicate keys being removed in the display, you can consider modifying the showTextModalDirective or the parseBigInt function. These components are responsible for parsing and rendering JSON content, and by altering their logic, you can change how JSON is processed and displayed. This could involve customizing the JSON parsing logic to preserve duplicate keys or providing an option for users to choose how JSON content is displayed, such as in raw text format.

Currently, there is no built-in configuration option in Apollo to change how JSON content is displayed or formatted, so any changes would need to be implemented in the codebase [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@nobodyiam nobodyiam added bug Categorizes issue or PR as related to a bug. help wanted labels Dec 21, 2024
@nobodyiam
Copy link
Member

这确实是一个可以改进的点,在 JSON 的标准(RFC 8259)中规定,每个键在一个对象中应该是唯一的,不过具体实现的行为确实会不太一样。

   When the names within an object are not
   unique, the behavior of software that receives such an object is
   unpredictable.  Many implementations report the last name/value pair
   only.  Other implementations report an error or fail to parse the
   object, and some implementations report all of the name/value pairs,
   including duplicates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Categorizes issue or PR as related to a bug. help wanted
Projects
None yet
Development

No branches or pull requests

2 participants