@@ -3882,9 +3882,9 @@ select json_pretty('{"a":["b", "c"], "d": {"e":"f"}}');
3882
3882
(1 row)
3883
3883
3884
3884
select json_concat('{"d": "test", "a": [1, 2]}', '{"g": "test2", "c": {"c1":1, "c2":2}}');
3885
- json_concat
3886
- -------------------------------------------------------------------
3887
- {"a": [1, 2], "c": {"c1": 1, "c2": 2}, "d": "test", "g": "test2"}
3885
+ json_concat
3886
+ -----------------------------------------------------------------
3887
+ {"a": [1, 2], "c": {"c1":1, "c2":2}, "d": "test", "g": "test2"}
3888
3888
(1 row)
3889
3889
3890
3890
select '{"aa":1 , "b":2, "cq":3}'::json || '{"cq":"l", "b":"g", "fg":false}';
@@ -4146,93 +4146,93 @@ select '["a","b","c"]'::json - -4;
4146
4146
(1 row)
4147
4147
4148
4148
select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{n}', '[1,2,3]');
4149
- json_set
4150
- --------------------------------------------------------------------------
4151
- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": [1, 2, 3]}
4149
+ json_set
4150
+ --------------------------------------------------------------------
4151
+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1":[2,3]}, "n": [1,2, 3]}
4152
4152
(1 row)
4153
4153
4154
4154
select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{b,-1}', '[1,2,3]');
4155
- json_set
4156
- -----------------------------------------------------------------------------
4157
- {"a": 1, "b": [1, [1, 2, 3]], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
4155
+ json_set
4156
+ ------------------------------------------------------------------------
4157
+ {"a": 1, "b": [1, [1,2, 3]], "c": {"1":2}, "d": {"1":[2,3]}, "n": null}
4158
4158
(1 row)
4159
4159
4160
4160
select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{d,1,0}', '[1,2,3]');
4161
- json_set
4162
- -----------------------------------------------------------------------------
4163
- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [[1, 2, 3], 3]}, "n": null}
4161
+ json_set
4162
+ -------------------------------------------------------------------------
4163
+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1": [[1,2, 3], 3]}, "n": null}
4164
4164
(1 row)
4165
4165
4166
4166
select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{d,NULL,0}', '[1,2,3]');
4167
4167
ERROR: path element at position 2 is null
4168
4168
select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{n}', '{"1": 2}');
4169
- json_set
4170
- -------------------------------------------------------------------------
4171
- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": {"1": 2}}
4169
+ json_set
4170
+ ---------------------------------------------------------------------
4171
+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1":[2,3]}, "n": {"1": 2}}
4172
4172
(1 row)
4173
4173
4174
4174
select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{b,-1}', '{"1": 2}');
4175
- json_set
4176
- ----------------------------------------------------------------------------
4177
- {"a": 1, "b": [1, {"1": 2}], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
4175
+ json_set
4176
+ -------------------------------------------------------------------------
4177
+ {"a": 1, "b": [1, {"1": 2}], "c": {"1":2}, "d": {"1":[2,3]}, "n": null}
4178
4178
(1 row)
4179
4179
4180
4180
select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{d,1,0}', '{"1": 2}');
4181
- json_set
4182
- ----------------------------------------------------------------------------
4183
- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [{"1": 2}, 3]}, "n": null}
4181
+ json_set
4182
+ --------------------------------------------------------------------------
4183
+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1": [{"1": 2}, 3]}, "n": null}
4184
4184
(1 row)
4185
4185
4186
4186
select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{d,NULL,0}', '{"1": 2}');
4187
4187
ERROR: path element at position 2 is null
4188
4188
select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{b,-1}', '"test"');
4189
- json_set
4190
- --------------------------------------------------------------------------
4191
- {"a": 1, "b": [1, "test"], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
4189
+ json_set
4190
+ -----------------------------------------------------------------------
4191
+ {"a": 1, "b": [1, "test"], "c": {"1":2}, "d": {"1":[2,3]}, "n": null}
4192
4192
(1 row)
4193
4193
4194
4194
select json_set('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json, '{b,-1}', '{"f": "test"}');
4195
- json_set
4196
- ---------------------------------------------------------------------------------
4197
- {"a": 1, "b": [1, {"f": "test"}], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
4195
+ json_set
4196
+ ------------------------------------------------------------------------------
4197
+ {"a": 1, "b": [1, {"f": "test"}], "c": {"1":2}, "d": {"1":[2,3]}, "n": null}
4198
4198
(1 row)
4199
4199
4200
4200
select json_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{n}');
4201
- json_delete_path
4202
- ----------------------------------------------------------
4203
- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}}
4201
+ json_delete_path
4202
+ ------------------------------------------------------
4203
+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1":[2,3]}}
4204
4204
(1 row)
4205
4205
4206
4206
select json_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{b,-1}');
4207
- json_delete_path
4208
- ------------------------------------------------------------------
4209
- {"a": 1, "b": [1], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
4207
+ json_delete_path
4208
+ ---------------------------------------------------------------
4209
+ {"a": 1, "b": [1], "c": {"1":2}, "d": {"1":[2,3]}, "n": null}
4210
4210
(1 row)
4211
4211
4212
4212
select json_delete_path('{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}', '{d,1,0}');
4213
- json_delete_path
4214
- ------------------------------------------------------------------
4215
- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [3]}, "n": null}
4213
+ json_delete_path
4214
+ ----------------------------------------------------------------
4215
+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1": [3]}, "n": null}
4216
4216
(1 row)
4217
4217
4218
4218
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json #- '{n}';
4219
- ?column?
4220
- ----------------------------------------------------------
4221
- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [2, 3]}}
4219
+ ?column?
4220
+ ------------------------------------------------------
4221
+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1":[2,3]}}
4222
4222
(1 row)
4223
4223
4224
4224
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json #- '{b,-1}';
4225
- ?column?
4226
- ------------------------------------------------------------------
4227
- {"a": 1, "b": [1], "c": {"1": 2}, "d": {"1": [2, 3]}, "n": null}
4225
+ ?column?
4226
+ ---------------------------------------------------------------
4227
+ {"a": 1, "b": [1], "c": {"1":2}, "d": {"1":[2,3]}, "n": null}
4228
4228
(1 row)
4229
4229
4230
4230
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json #- '{b,-1e}'; -- invalid array subscript
4231
4231
ERROR: path element at position 2 is not an integer: "-1e"
4232
4232
select '{"n":null, "a":1, "b":[1,2], "c":{"1":2}, "d":{"1":[2,3]}}'::json #- '{d,1,0}';
4233
- ?column?
4234
- ------------------------------------------------------------------
4235
- {"a": 1, "b": [1, 2], "c": {"1": 2}, "d": {"1": [3]}, "n": null}
4233
+ ?column?
4234
+ ----------------------------------------------------------------
4235
+ {"a": 1, "b": [1,2], "c": {"1":2}, "d": {"1": [3]}, "n": null}
4236
4236
(1 row)
4237
4237
4238
4238
-- empty structure and error conditions for delete and replace
@@ -4291,69 +4291,69 @@ select json_set('[]','{1}','"b"', false);
4291
4291
-- json_set adding instead of replacing
4292
4292
-- prepend to array
4293
4293
select json_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{b,-33}','{"foo":123}');
4294
- json_set
4295
- -------------------------------------------------------
4296
- {"a": 1, "b": [{"foo": 123}, 0, 1, 2], "c": {"d": 4}}
4294
+ json_set
4295
+ -----------------------------------------------------
4296
+ {"a": 1, "b": [{"foo":123}, 0, 1, 2], "c": {"d":4}}
4297
4297
(1 row)
4298
4298
4299
4299
-- append to array
4300
4300
select json_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{b,33}','{"foo":123}');
4301
- json_set
4302
- -------------------------------------------------------
4303
- {"a": 1, "b": [0, 1, 2, {"foo": 123}], "c": {"d": 4}}
4301
+ json_set
4302
+ -----------------------------------------------------
4303
+ {"a": 1, "b": [0, 1, 2, {"foo":123}], "c": {"d":4}}
4304
4304
(1 row)
4305
4305
4306
4306
-- check nesting levels addition
4307
4307
select json_set('{"a":1,"b":[4,5,[0,1,2],6,7],"c":{"d":4}}','{b,2,33}','{"foo":123}');
4308
- json_set
4309
- ---------------------------------------------------------------------
4310
- {"a": 1, "b": [4, 5, [0, 1, 2, {"foo": 123}], 6, 7], "c": {"d": 4}}
4308
+ json_set
4309
+ -------------------------------------------------------------------
4310
+ {"a": 1, "b": [4, 5, [0, 1, 2, {"foo":123}], 6, 7], "c": {"d":4}}
4311
4311
(1 row)
4312
4312
4313
4313
-- add new key
4314
4314
select json_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{c,e}','{"foo":123}');
4315
- json_set
4316
- ------------------------------------------------------------
4317
- {"a": 1, "b": [0, 1, 2], "c": {"d": 4, "e": {"foo": 123}}}
4315
+ json_set
4316
+ ---------------------------------------------------------
4317
+ {"a": 1, "b": [0,1, 2], "c": {"d": 4, "e": {"foo":123}}}
4318
4318
(1 row)
4319
4319
4320
4320
-- adding doesn't do anything if elements before last aren't present
4321
4321
select json_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{x,-33}','{"foo":123}');
4322
- json_set
4323
- -----------------------------------------
4324
- {"a": 1, "b": [0, 1, 2], "c": {"d": 4}}
4322
+ json_set
4323
+ --------------------------------------
4324
+ {"a": 1, "b": [0,1, 2], "c": {"d":4}}
4325
4325
(1 row)
4326
4326
4327
4327
select json_set('{"a":1,"b":[0,1,2],"c":{"d":4}}','{x,y}','{"foo":123}');
4328
- json_set
4329
- -----------------------------------------
4330
- {"a": 1, "b": [0, 1, 2], "c": {"d": 4}}
4328
+ json_set
4329
+ --------------------------------------
4330
+ {"a": 1, "b": [0,1, 2], "c": {"d":4}}
4331
4331
(1 row)
4332
4332
4333
4333
-- add to empty object
4334
4334
select json_set('{}','{x}','{"foo":123}');
4335
- json_set
4336
- ---------------------
4337
- {"x": {"foo": 123}}
4335
+ json_set
4336
+ --------------------
4337
+ {"x": {"foo":123}}
4338
4338
(1 row)
4339
4339
4340
4340
--add to empty array
4341
4341
select json_set('[]','{0}','{"foo":123}');
4342
- json_set
4343
- ----------------
4344
- [{"foo": 123}]
4342
+ json_set
4343
+ ---------------
4344
+ [{"foo":123}]
4345
4345
(1 row)
4346
4346
4347
4347
select json_set('[]','{99}','{"foo":123}');
4348
- json_set
4349
- ----------------
4350
- [{"foo": 123}]
4348
+ json_set
4349
+ ---------------
4350
+ [{"foo":123}]
4351
4351
(1 row)
4352
4352
4353
4353
select json_set('[]','{-99}','{"foo":123}');
4354
- json_set
4355
- ----------------
4356
- [{"foo": 123}]
4354
+ json_set
4355
+ ---------------
4356
+ [{"foo":123}]
4357
4357
(1 row)
4358
4358
4359
4359
select json_set('{"a": [1, 2, 3]}', '{a, non_integer}', '"new_value"');