NewFixedKeysObjectBuilder creates JSON object builder for the specified set of fixed, unique keys.
(keys []string)
| 419 | // NewFixedKeysObjectBuilder creates JSON object builder for the specified |
| 420 | // set of fixed, unique keys. |
| 421 | func NewFixedKeysObjectBuilder(keys []string) (*FixedKeysObjectBuilder, error) { |
| 422 | sort.Strings(keys) |
| 423 | pairs := make([]jsonKeyValuePair, len(keys)) |
| 424 | keyOrd := make(map[string]int, len(keys)) |
| 425 | |
| 426 | for i, k := range keys { |
| 427 | if _, exists := keyOrd[k]; exists { |
| 428 | return nil, errors.AssertionFailedf("expected unique keys, found %v", keys) |
| 429 | } |
| 430 | pairs[i] = jsonKeyValuePair{k: jsonString(keys[i])} |
| 431 | keyOrd[k] = i |
| 432 | } |
| 433 | |
| 434 | return &FixedKeysObjectBuilder{ |
| 435 | pairs: pairs, |
| 436 | keyOrd: keyOrd, |
| 437 | }, nil |
| 438 | } |
| 439 | |
| 440 | // Set sets the value for the specified key. |
| 441 | // All previously configured keys must be set before calling Build. |
nothing calls this directly
no test coverage detected
searching dependent graphs…