-
-
Notifications
You must be signed in to change notification settings - Fork 111
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
feat: enhance WriteToFileAsJSON
with pretty-printing support
#783
Conversation
📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 WalkthroughWalkthroughThe changes in this pull request focus on the Changes
Suggested labels
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
pkg/utils/json_utils.go (1)
91-91
: Consider extracting common jsoniter config.While the short declaration is good, I notice that we have similar jsoniter configs repeated in multiple functions. Consider extracting this into a shared config variable.
package utils import (...) +var defaultJSONConfig = jsoniter.Config{ + EscapeHTML: false, + MarshalFloatWith6Digits: true, + ObjectFieldMustBeSimpleString: true, + SortMapKeys: true, + ValidateJsonRawMessage: true, +} // ... rest of the fileThis would reduce duplication and make config changes easier to maintain.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
pkg/utils/json_utils.go
(4 hunks)
🔇 Additional comments (2)
pkg/utils/json_utils.go (2)
58-58
: LGTM! Clean variable declaration.
The short variable declaration style is idiomatic Go and improves readability.
74-74
: LGTM! Consistent style.
The short variable declaration maintains consistency with the previous changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @RoseSecurity
These changes were released in v1.106.1. |
what
ConvertToJSON
utility withjson.MarshalIndent
to produce formatted JSONwhy
This PR improves the
WriteToFileAsJSON
function by introducing pretty-printing for JSON outputs. Previously, the function serialized JSON using a compact format, which could make the resulting files harder to read. With this change, all JSON written by this function will now be formatted with indentation, making it easier for developers and users to inspect and debug the generated filesThis specifically addresses Pretty Json Formatting from auto backend generation #778 , which previously rendered auto-generated backends as:
With this addition, the output appears as:
references
Summary by CodeRabbit
Summary by CodeRabbit