Skip to content

General: Replace Moshi JSON library with built-in serialization#442

Merged
d4rken merged 2 commits intomainfrom
refactor/replace-moshi-with-kotlinx-serialization
Mar 9, 2026
Merged

General: Replace Moshi JSON library with built-in serialization#442
d4rken merged 2 commits intomainfrom
refactor/replace-moshi-with-kotlinx-serialization

Conversation

@d4rken
Copy link
Copy Markdown
Member

@d4rken d4rken commented Mar 9, 2026

What changed

Removed the Moshi JSON library entirely, completing the migration to the built-in kotlinx.serialization that was already partially in place. No user-facing behavior change — all stored settings, device profiles, and cached data remain readable.

Technical Context

  • Most classes already carried dual annotations (Moshi + kotlinx). This PR strips the Moshi annotations and deletes the Moshi adapters, ProGuard rules, and build dependency.
  • PodDeviceCache was the only runtime component still using Moshi directly — migrated to the existing @SerializationCapod Json instance.
  • Created MapIntByteArrayBase64Serializer to preserve the existing on-disk format for BleScanResult cache files (Map<Int, ByteArray> serialized as {"76": "<base64>"})
  • Added explicit @SerialName on all data class fields to lock in the wire format contract and prevent accidental breakage from property renames.
  • classDiscriminator = "type" set explicitly in the Json config to match the existing Moshi polymorphic adapter behavior for DeviceProfile subtypes.
  • Okio is intentionally kept — still used by ProximityMessage and RPAChecker, unrelated to Moshi.
  • Existing compat tests converted to pure kotlinx round-trip tests while retaining legacy fixture-based decode tests for backward compatibility verification.

Remove Moshi dependency entirely, completing the migration to kotlinx.serialization. All JSON serialization now uses kotlinx with explicit @SerialName annotations for wire format stability.

- Migrate PodDeviceCache from Moshi to kotlinx Json injection

- Add MapIntByteArrayBase64Serializer for BleScanResult cache compat

- Strip @JsonClass/@JSON annotations from all dual-annotated classes

- Delete Moshi adapters, ProGuard rules, and build config

- Convert compat tests to pure kotlinx round-trip tests
@d4rken d4rken added the enhancement Add a new feature of improve an existing feature label Mar 9, 2026
@d4rken d4rken merged commit 44cd0ee into main Mar 9, 2026
9 checks passed
@d4rken d4rken deleted the refactor/replace-moshi-with-kotlinx-serialization branch March 9, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Add a new feature of improve an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant