-
Notifications
You must be signed in to change notification settings - Fork 20
Serialize ValidationMessage to JSON #331
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
Conversation
Signed-off-by: Arthit Suriyawongkul <[email protected]>
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.
Pull request overview
This PR adds JSON serialization support for validation messages to fix issue #330. The main change introduces a new get_validation_messages_json function that converts ValidationMessage objects into JSON-serializable dictionaries, including optional context details (spdx_id, parent_id, element_type) when verbose mode is enabled. The PR also refactors attribute access in base_checker.py to use defensive getattr calls with defaults.
Key changes:
- Added
get_validation_messages_jsonfunction to serialize validation messages with optional context details - Modified
output_jsonmethod to use the new serialization function instead of simple string conversion - Applied defensive programming pattern with
getattrthroughout the output methods inbase_checker.py
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ntia_conformance_checker/report.py | Added get_validation_messages_json function to serialize validation messages to JSON format with optional context details |
| ntia_conformance_checker/base_checker.py | Updated output methods to use the new JSON serialization function and applied defensive attribute access pattern |
| a.json | Example output file showing the new JSON structure (should be removed from PR) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Arthit Suriyawongkul <[email protected]>
Signed-off-by: Arthit Suriyawongkul <[email protected]>
Signed-off-by: Arthit Suriyawongkul <[email protected]>
Signed-off-by: Arthit Suriyawongkul <[email protected]>
jspeed-meyers
left a comment
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.
LGTM! Thank you.
Signed-off-by: Arthit Suriyawongkul <[email protected]>
To fix #330
The serialized validation messages will be something like: