(key string, to JSON, createMissing bool)
| 2374 | var errCannotDeleteFromObject = pgerror.WithCandidateCode(errors.New("cannot delete from object using integer index"), pgcode.InvalidParameterValue) |
| 2375 | |
| 2376 | func (j jsonObject) SetKey(key string, to JSON, createMissing bool) (jsonObject, error) { |
| 2377 | result := make(jsonObject, 0, len(j)+1) |
| 2378 | curIdx := 0 |
| 2379 | |
| 2380 | for curIdx < len(j) && string(j[curIdx].k) < key { |
| 2381 | result = append(result, j[curIdx]) |
| 2382 | curIdx++ |
| 2383 | } |
| 2384 | |
| 2385 | keyAlreadyExists := curIdx < len(j) && string(j[curIdx].k) == key |
| 2386 | if createMissing || keyAlreadyExists { |
| 2387 | result = append(result, jsonKeyValuePair{ |
| 2388 | k: jsonString(key), |
| 2389 | v: to, |
| 2390 | }) |
| 2391 | } |
| 2392 | if keyAlreadyExists { |
| 2393 | curIdx++ |
| 2394 | } |
| 2395 | |
| 2396 | for curIdx < len(j) { |
| 2397 | result = append(result, j[curIdx]) |
| 2398 | curIdx++ |
| 2399 | } |
| 2400 | |
| 2401 | return result, nil |
| 2402 | } |
| 2403 | |
| 2404 | func (j jsonArray) RemoveString(s string) (JSON, bool, error) { |
| 2405 | b := NewArrayBuilder(j.Len()) |
no test coverage detected