Skip to content

Updated the schema JSON format, schema comparison and tests#1159

Merged
VisLab merged 2 commits intohed-standard:mainfrom
VisLab:web_update
Dec 8, 2025
Merged

Updated the schema JSON format, schema comparison and tests#1159
VisLab merged 2 commits intohed-standard:mainfrom
VisLab:web_update

Conversation

@VisLab
Copy link
Member

@VisLab VisLab commented Dec 8, 2025

Fixes the conflict with attributes in outputted JSON format.

Copy link
Contributor

Copilot AI left a 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 updates the JSON schema output format to omit empty list attributes rather than serializing them as empty arrays. This fixes a conflict in the JSON format where attributes like suggestedTag, relatedTag, valueClass, and unitClass were being written even when empty.

Key changes:

  • Modified JSON serialization to conditionally include list attributes only when non-empty
  • Updated existing tests to verify empty lists are omitted, not present as empty arrays
  • Added comprehensive new tests for empty list omission and extras section roundtrip

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
hed/schema/schema_io/schema2json.py Changed build_attributes_dict to check if list attributes are non-empty before adding them to the output dictionary
tests/schema/test_json_explicit_attributes.py Updated test_empty_lists_omitted to verify empty lists are completely omitted rather than present as empty arrays
tests/schema/test_schema_format_roundtrip.py Added three new comprehensive tests: test_json_empty_list_attributes_omitted, test_extras_sections_roundtrip, test_library_schema_extras_roundtrip, and test_library_schema_score

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@VisLab VisLab merged commit 5063fc5 into hed-standard:main Dec 8, 2025
20 checks passed
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.

2 participants