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

Method Build

pkg/util/json/json.go:270–287  ·  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

268// Build returns a JSON object built from a key value pair sequence. After that,
269// it should not be modified any longer.
270func (b *ObjectBuilder) Build() JSON {
271 if b.pairs == nil {
272 panic(errors.AssertionFailedf(msgModifyAfterBuild))
273 }
274 orders := make([]int, len(b.pairs))
275 for i := range orders {
276 orders[i] = i
277 }
278 sorter := pairSorter{
279 pairs: b.pairs,
280 orders: orders,
281 hasNonUnique: false,
282 }
283 b.pairs = nil
284 sort.Sort(&sorter)
285 sorter.unique()
286 return jsonObject(sorter.pairs)
287}
288
289// pairSorter sorts and uniqueifies JSON pairs. In order to keep
290// the last one for pairs with the same key while sort.Sort is

Callers 2

normalizeMethod · 0.95
AsJSONFunction · 0.95

Calls 2

uniqueMethod · 0.95
jsonObjectTypeAlias · 0.85

Tested by

no test coverage detected