Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add json array check when determining CBOR of JSON encoding #896

Merged
merged 5 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/trigger/messagebus/messaging.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (trigger *Trigger) processMessage(logger logger.LoggingClient, triggerTopic
contentType = appContext.ResponseContentType()
} else {
contentType = common.ContentTypeJSON
if appContext.ResponseData()[0] != byte('{') {
if appContext.ResponseData()[0] != byte('{') && appContext.ResponseData()[0] != byte('[') {
// If not JSON then assume it is CBOR
contentType = common.ContentTypeCBOR
}
Expand Down
2 changes: 1 addition & 1 deletion internal/trigger/mqtt/mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (trigger *Trigger) messageHandler(client pahoMqtt.Client, message pahoMqtt.

data := message.Payload()
contentType := common.ContentTypeJSON
if data[0] != byte('{') {
if data[0] != byte('{') && data[0] != byte('[') {
// If not JSON then assume it is CBOR
contentType = common.ContentTypeCBOR
}
Expand Down