Skip to content

Commit

Permalink
fix: Add json array check when determining CBOR of JSON encoding (#896)
Browse files Browse the repository at this point in the history
* fix: Add json array check when determining CBOR of JSON encoding

Signed-off-by: phanvanhai <[email protected]>
  • Loading branch information
phanvanhai authored Jun 14, 2021
1 parent a453267 commit d07bca6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
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

0 comments on commit d07bca6

Please sign in to comment.