FetchPath implements the #> operator.
(j JSON, path []string)
| 2154 | |
| 2155 | // FetchPath implements the #> operator. |
| 2156 | func FetchPath(j JSON, path []string) (JSON, error) { |
| 2157 | var next JSON |
| 2158 | var err error |
| 2159 | for _, v := range path { |
| 2160 | next, err = j.FetchValKeyOrIdx(v) |
| 2161 | if next == nil { |
| 2162 | return nil, nil |
| 2163 | } |
| 2164 | if err != nil { |
| 2165 | return nil, err |
| 2166 | } |
| 2167 | j = next |
| 2168 | } |
| 2169 | return j, nil |
| 2170 | } |
| 2171 | |
| 2172 | var errCannotSetPathInScalar = pgerror.WithCandidateCode(errors.New("cannot set path in scalar"), pgcode.InvalidParameterValue) |
| 2173 |
no test coverage detected
searching dependent graphs…