Lossless, round-trippable JSON for dm2-dungeon #309

Closed
opened 2026-07-31 22:32:05 +02:00 by jqueuniet · 0 comments
Owner

Summary

Add a lossless, round-trippable JSON representation for dungeon.dat in dm2-dungeon,
alongside (not replacing) the existing lossy json::skproject interop dump.

Motivation

Underpins the dungeon editor (GUI, #305) and the browser dungeon viewer/editor behind
#301. The current json::skproject dump is one-way and lossy (retired-C#-tool interop;
start_map hardcoded to 0) and cannot serve as an editable representation.

Design

  • Reuse the owned-DTO + base64 + byte-exact-round-trip pattern established for saves
    (#308). Dungeon<'a> is borrowed, so an owned document model is required: build from
    Dungeon, feed the existing byte-exact write_to / to_bytes (per-section writers
    Map::to_bytes, Body::to_bytes, Columns::to_bytes are already round-trip-tested).
  • Keep json::skproject untouched (external interop); add a new lossless module.

Scope / acceptance

  • parse -> doc -> JSON string -> doc -> to_bytes == original bytes, byte-identical,
    over the dungeon fixtures in both LE and BE.
  • Out of scope: the web serialization scheme (#307) and graphics.

Labels

type/feature, area/dungeon, priority/low.

## Summary Add a lossless, round-trippable JSON representation for `dungeon.dat` in `dm2-dungeon`, **alongside** (not replacing) the existing lossy `json::skproject` interop dump. ## Motivation Underpins the dungeon editor (GUI, #305) and the browser dungeon viewer/editor behind #301. The current `json::skproject` dump is one-way and lossy (retired-C#-tool interop; `start_map` hardcoded to 0) and cannot serve as an editable representation. ## Design - Reuse the owned-DTO + base64 + byte-exact-round-trip pattern established for saves (#308). `Dungeon<'a>` is borrowed, so an owned document model is required: build from `Dungeon`, feed the existing byte-exact `write_to` / `to_bytes` (per-section writers `Map::to_bytes`, `Body::to_bytes`, `Columns::to_bytes` are already round-trip-tested). - Keep `json::skproject` untouched (external interop); add a new lossless module. ## Scope / acceptance - `parse -> doc -> JSON string -> doc -> to_bytes == original bytes`, byte-identical, over the dungeon fixtures in both LE and BE. - Out of scope: the web serialization scheme (#307) and graphics. ## Labels `type/feature`, `area/dungeon`, `priority/low`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jqueuniet/dm2-tools#309
No description provided.