diff --git a/util/jsonutil/jsonutil.go b/util/jsonutil/jsonutil.go index 1e460196fc4..2598044ff73 100644 --- a/util/jsonutil/jsonutil.go +++ b/util/jsonutil/jsonutil.go @@ -12,12 +12,17 @@ import ( "github.com/prebid/prebid-server/v3/errortypes" ) -var comma = byte(',') -var colon = byte(':') -var sqBracket = byte(']') -var closingCurlyBracket = byte('}') +const ( + comma byte = ',' + colon byte = ':' + sqBracket byte = ']' + closingCurlyBracket byte = '}' +) + +// RawMessage to allow replacing json with jsonutil +type RawMessage = json.RawMessage -// Finds element in json byte array with any level of nesting +// FindElement finds element in json byte array with any level of nesting func FindElement(extension []byte, elementNames ...string) (bool, int64, int64, error) { elementName := elementNames[0] buf := bytes.NewBuffer(extension) @@ -100,7 +105,7 @@ func FindElement(extension []byte, elementNames ...string) (bool, int64, int64, return found, startIndex, endIndex, nil } -// Drops element from json byte array +// DropElement drops element from json byte array // - Doesn't support drop element from json list // - Keys in the path can skip levels // - First found element will be removed