#1212: IdOnlySerializer.kt

projectforge-business/src/main/kotlin/org/projectforge/framework/json/IdOnlySerializer.kt JSON Serializer, projectforge-business/src/main/kotlin/org/projectforge/framework/json/IdOnlySerializer.kt 67 lines · 37 code · 24 comments · 6 blank
Jackson JsonSerializer<IdObject<*>> that serializes entity references to a compact {"id": ...} JSON object. Consults JsonThreadLocalContext to determine behavior: if preferEmbeddedSerializers or ignoreIdOnlySerializers is set, it falls back to full serialization or another registered serializer. Prevents deep object graphs by default.

Architecture

Serialization Decision Tree

  1. If value == null: write null
  2. If JsonThreadLocalContext.get() != null:
  3. Default: write {"id": value.id} (id may be null, written as appropriate JSON type via JsonUtils.writeField)

Integration

Git History

868d6abb7 2025 -> 2026
63081666f Source file headers: 2024-> 2025.
59519ee50 Json serialization refactored: IdOnlySerializer and IdsOnlySerializer introduced.
0237d5eba Json serialization refactored: IdOnlySerializer and IdsOnlySerializer introduced.
b6092df09 Copyright 2023 -> 2024
ab45d51fa Copyright 2001-2022 -> 2001-2023.