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

Method RemoveString

pkg/util/json/json.go:1309–1332  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

1307}
1308
1309func (j jsonArray) RemoveString(s string) (JSON, bool, error) {
1310 b := NewArrayBuilder(j.Len())
1311 removed := false
1312 for _, el := range j {
1313 // We want to remove only elements of string type.
1314 if el.Type() == StringJSONType {
1315 t, err := el.AsText()
1316 if err != nil {
1317 return nil, false, err
1318 }
1319 if *t != s {
1320 b.Add(el)
1321 } else {
1322 removed = true
1323 }
1324 } else {
1325 b.Add(el)
1326 }
1327 }
1328 if removed {
1329 return b.Build(), removed, nil
1330 }
1331 return j, false, nil
1332}
1333
1334func (j jsonObject) RemoveString(s string) (JSON, bool, error) {
1335 idx, ok := findPairIndexByKey(j, s)

Callers

nothing calls this directly

Calls 6

LenMethod · 0.95
AddMethod · 0.95
BuildMethod · 0.95
NewArrayBuilderFunction · 0.85
TypeMethod · 0.65
AsTextMethod · 0.65

Tested by

no test coverage detected