DeepSet sets a path to a value in a JSON document. Largely follows the same semantics as setValKeyOrIdx, but with a path. Implements the jsonb_set builtin.
(j JSON, path []string, to JSON, createMissing bool)
| 2224 | // Largely follows the same semantics as setValKeyOrIdx, but with a path. |
| 2225 | // Implements the jsonb_set builtin. |
| 2226 | func DeepSet(j JSON, path []string, to JSON, createMissing bool) (JSON, error) { |
| 2227 | if j.isScalar() { |
| 2228 | return nil, errCannotSetPathInScalar |
| 2229 | } |
| 2230 | return deepSet(j, path, to, createMissing) |
| 2231 | } |
| 2232 | |
| 2233 | func deepSet(j JSON, path []string, to JSON, createMissing bool) (JSON, error) { |
| 2234 | switch len(path) { |