Skip to content

Commit

Permalink
Adds RawMessage type alias, move vars to consts, and fixes some godoc…
Browse files Browse the repository at this point in the history
… comments.
  • Loading branch information
scr-oath committed Jan 31, 2025
1 parent f2d62ef commit 620faf1
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions util/jsonutil/jsonutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 620faf1

Please sign in to comment.