FetchPath implements the #> operator.
(j JSON, path []string)
| 1059 | |
| 1060 | // FetchPath implements the #> operator. |
| 1061 | func FetchPath(j JSON, path []string) (JSON, error) { |
| 1062 | var next JSON |
| 1063 | var err error |
| 1064 | for _, v := range path { |
| 1065 | next, err = j.FetchValKeyOrIdx(v) |
| 1066 | if next == nil { |
| 1067 | return nil, nil |
| 1068 | } |
| 1069 | if err != nil { |
| 1070 | return nil, err |
| 1071 | } |
| 1072 | j = next |
| 1073 | } |
| 1074 | return j, nil |
| 1075 | } |
| 1076 | |
| 1077 | var errCannotSetPathInScalar = pgerror.WithCandidateCode(errors.New("cannot set path in scalar"), pgcode.InvalidParameterValue) |
| 1078 |
no test coverage detected
searching dependent graphs…