(key string, to JSON, createMissing bool)
| 1279 | var errCannotDeleteFromObject = pgerror.WithCandidateCode(errors.New("cannot delete from object using integer index"), pgcode.InvalidParameterValue) |
| 1280 | |
| 1281 | func (j jsonObject) SetKey(key string, to JSON, createMissing bool) (jsonObject, error) { |
| 1282 | result := make(jsonObject, 0, len(j)+1) |
| 1283 | curIdx := 0 |
| 1284 | |
| 1285 | for curIdx < len(j) && string(j[curIdx].k) < key { |
| 1286 | result = append(result, j[curIdx]) |
| 1287 | curIdx++ |
| 1288 | } |
| 1289 | |
| 1290 | keyAlreadyExists := curIdx < len(j) && string(j[curIdx].k) == key |
| 1291 | if createMissing || keyAlreadyExists { |
| 1292 | result = append(result, jsonKeyValuePair{ |
| 1293 | k: jsonString(key), |
| 1294 | v: to, |
| 1295 | }) |
| 1296 | } |
| 1297 | if keyAlreadyExists { |
| 1298 | curIdx++ |
| 1299 | } |
| 1300 | |
| 1301 | for curIdx < len(j) { |
| 1302 | result = append(result, j[curIdx]) |
| 1303 | curIdx++ |
| 1304 | } |
| 1305 | |
| 1306 | return result, nil |
| 1307 | } |
| 1308 | |
| 1309 | func (j jsonArray) RemoveString(s string) (JSON, bool, error) { |
| 1310 | b := NewArrayBuilder(j.Len()) |
no test coverage detected