Skip to content

Store nil JSON assignments as null#10

Merged
atdrendel merged 2 commits into
mainfrom
fix-inconsistent-nulls
Jun 25, 2026
Merged

Store nil JSON assignments as null#10
atdrendel merged 2 commits into
mainfrom
fix-inconsistent-nulls

Conversation

@atdrendel

Copy link
Copy Markdown
Contributor
  • Add removeValue(forKey:) for explicit dictionary key removal
  • Distinguish missing optional JSON values from explicit NSNull comparisons
  • Document and test nil subscript assignment behavior

- Add removeValue(forKey:) for explicit dictionary key removal
- Distinguish missing optional JSON values from explicit NSNull comparisons
- Document and test nil subscript assignment behavior
Copilot AI review requested due to automatic review settings June 25, 2026 20:36

Copilot AI left a comment

Copy link
Copy Markdown

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 adjusts JSON dictionary subscript semantics so assigning nil stores an explicit JSON null value (instead of removing the key), adds an explicit removeValue(forKey:) API for key removal, and updates tests/docs to cover the new behavior and null-vs-missing distinction.

Changes:

  • Store nil dictionary subscript assignments as JSON.null across JSON and JSON? subscripts.
  • Add removeValue(forKey:) to explicitly remove keys from JSON dictionaries.
  • Add/extend tests and README guidance for nil assignment behavior and distinguishing missing keys from explicit null (including NSNull comparisons).

Reviewed changes

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

File Description
Tests/JSONTests/JSONTests.swift Adds coverage for nil subscript assignment storing JSON.null, removeValue(forKey:), and NSNull comparison behavior.
Sources/JSON/JSON.swift Implements nil-as-null subscript setters, adds removeValue(forKey:), and updates NSNull equality to distinguish missing vs explicit null.
README.md Documents the new nil subscript assignment semantics and the new explicit key removal API.

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

@atdrendel atdrendel merged commit 05c5b78 into main Jun 25, 2026
1 check passed
@atdrendel atdrendel deleted the fix-inconsistent-nulls branch June 25, 2026 21:23
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