ExtractValues extracts the raw JSON values of the specified keys from the JSON-encoded args.
(encodedArgs []byte, uniqueKeys []string)
| 14 | |
| 15 | // ExtractValues extracts the raw JSON values of the specified keys from the JSON-encoded args. |
| 16 | func ExtractValues(encodedArgs []byte, uniqueKeys []string) []string { |
| 17 | // Use GetManyBytes to retrieve multiple values at once |
| 18 | results := gjson.GetManyBytes(encodedArgs, uniqueKeys...) |
| 19 | |
| 20 | uniqueValues := make([]string, len(results)) |
| 21 | for i, res := range results { |
| 22 | if res.Exists() { |
| 23 | uniqueValues[i] = res.Raw // Use Raw to get the JSON-encoded value |
| 24 | } else { |
| 25 | // Handle missing keys as "undefined" (they'll be skipped when |
| 26 | // building the key). We don't want to use "null" here because the |
| 27 | // JSON may actually contain "null" as a value. |
| 28 | uniqueValues[i] = "undefined" |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | return uniqueValues |
| 33 | } |
| 34 | |
| 35 | type uniqueFieldCacheKey struct { |
| 36 | typ reflect.Type |
no outgoing calls
searching dependent graphs…