fix: parse AlarmComment.comment into AlarmCommentJsonNode on deserialization#61
Merged
deaflynx merged 1 commit intothingsboard:devfrom Apr 27, 2026
Merged
Conversation
…ization AlarmComment.fromJson now normalizes the dynamic comment field into a typed AlarmCommentJsonNode for both Map and legacy String formats. AlarmComment.toJson properly serializes it back for the API.
4 tasks
vvlladd28
approved these changes
Apr 27, 2026
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AlarmComment.fromJsonnow automatically parses thedynamic commentfield into a typedAlarmCommentJsonNode, handling bothMap(normal) andString(legacy mobile-posted) formats.AlarmComment.toJsonproperly serializes it back for the API.Root cause
The mobile app was posting comments as raw strings instead of
{"text": "..."}objects. The server stores whatever it receives, so on read thecommentfield could be either aMapor aString. Sincecommentis typed asdynamic, any consumer accessing.textor.editedwould crash withNoSuchMethodErroron the wrong type.Changes
AlarmComment.fromJson— calls_parseComment()to normalizecommentintoAlarmCommentJsonNodeAlarmComment.toJson— serializesAlarmCommentJsonNodeback to aMapvia.toJson()_parseCommentstatic method — handlesMap→AlarmCommentJsonNode.fromJson(),String→ wraps inAlarmCommentJsonNode(text: ...), other → pass-throughTest plan
commentas a JSON object ({"text": "hello"}) — producesAlarmCommentJsonNodecommentas a raw string ("hello") — producesAlarmCommentJsonNodewithtext: "hello"AlarmCommentwithAlarmCommentJsonNodecomment — produces correct JSON mapAlarmService— round-trips correctly