MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / Build

Method Build

pkg/util/json/json.go:386–408  ·  view source on GitHub ↗

Build returns a JSON object built from a key value pair sequence. After that, it should not be modified any longer.

()

Source from the content-addressed store, hash-verified

384// Build returns a JSON object built from a key value pair sequence. After that,
385// it should not be modified any longer.
386func (b *ObjectBuilder) Build() JSON {
387 if b.built {
388 panic(errors.AssertionFailedf(msgModifyAfterBuild))
389 }
390 b.built = true
391 if b.unordered {
392 return jsonObject(b.pairs)
393 }
394
395 orders := make([]int, len(b.pairs))
396 for i := range orders {
397 orders[i] = i
398 }
399 sorter := pairSorter{
400 pairs: b.pairs,
401 orders: orders,
402 hasNonUnique: false,
403 }
404 b.pairs = nil
405 sort.Sort(&sorter)
406 sorter.unique()
407 return jsonObject(sorter.pairs)
408}
409
410// FixedKeysObjectBuilder is a JSON object builder that builds
411// an object for the specified fixed set of unique keys.

Callers 1

AsJSONFunction · 0.95

Calls 2

uniqueMethod · 0.95
jsonObjectTypeAlias · 0.85

Tested by

no test coverage detected