Skip to content

Commit 52222f7

Browse files
committed
json output error on unknown tags, fixes #57
1 parent 1cf03c5 commit 52222f7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

cmd/e3dc/json_output_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,11 @@ func TestJSONSimpleMessage_MarshalJSON(t *testing.T) {
154154
[]byte(`{"EMS_MANUAL_CHARGE_LASTSTART":"1970-01-01T00:00:00Z"}`),
155155
false,
156156
},
157+
{"Unknown Tag to String key",
158+
JSONMessage{25166461: 0},
159+
[]byte(`{"25166461":0}`),
160+
false,
161+
},
157162
}
158163
for _, tt := range tests {
159164
t.Run(tt.name, func(t *testing.T) {

rscp/tag_functions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func (t Tag) MarshalJSON() ([]byte, error) {
2323
if t.IsATag() {
2424
return json.Marshal(t.String())
2525
}
26-
return []byte(fmt.Sprintf("%d", t)), nil
26+
return []byte(fmt.Sprintf("\"%d\"", t)), nil
2727
}
2828

2929
// UnmarshalJSON implements the json.Unmarshaler interface for Tag

0 commit comments

Comments
 (0)