Skip to content

Commit

Permalink
keiths feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
dpaasman00 committed Nov 8, 2023
1 parent 8bce2fe commit 5001091
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions receiver/httpreceiver/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,18 +217,19 @@ func (r *httpLogsReceiver) processLogs(now pcommon.Timestamp, logs []map[string]

// parsePayload transforms the payload into []map[string]interface structure
func parsePayload(payload []byte) ([]map[string]interface{}, error) {
rawLogsArray := []json.RawMessage{}
rawLogObject := json.RawMessage{}
if err := json.Unmarshal(payload, &rawLogsArray); err != nil {
if err.Error() == "json: cannot unmarshal object into Go value of type []json.RawMessage" {
if err = json.Unmarshal(payload, &rawLogObject); err != nil {
return nil, err
}
return parseJSONObject(rawLogObject)
if string(payload[0]) == "[" {
rawLogsArray := []json.RawMessage{}
if err := json.Unmarshal(payload, &rawLogsArray); err != nil {
return nil, err
}
return parseJSONArray(rawLogsArray)
}

rawLogObject := json.RawMessage{}
if err := json.Unmarshal(payload, &rawLogObject); err != nil {
return nil, err
}
return parseJSONArray(rawLogsArray)
return parseJSONObject(rawLogObject)
}

func parseJSONObject(rawLog json.RawMessage) ([]map[string]interface{}, error) {
Expand Down

0 comments on commit 5001091

Please sign in to comment.