Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
9d5df20e
Commit
9d5df20e
authored
Dec 20, 2015
by
Clayton Coleman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jsonpath: Handle interface{}(nil) as empty array
parent
ca69c2e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
3 deletions
+6
-3
jsonpath.go
pkg/util/jsonpath/jsonpath.go
+6
-3
No files found.
pkg/util/jsonpath/jsonpath.go
View file @
9d5df20e
...
@@ -205,7 +205,7 @@ func (j *JSONPath) evalIdentifier(input []reflect.Value, node *IdentifierNode) (
...
@@ -205,7 +205,7 @@ func (j *JSONPath) evalIdentifier(input []reflect.Value, node *IdentifierNode) (
return
results
,
fmt
.
Errorf
(
"not in range, nothing to end"
)
return
results
,
fmt
.
Errorf
(
"not in range, nothing to end"
)
}
}
default
:
default
:
return
input
,
fmt
.
Errorf
(
"unreco
n
gnized identifier %v"
,
node
.
Name
)
return
input
,
fmt
.
Errorf
(
"unrecognized identifier %v"
,
node
.
Name
)
}
}
return
results
,
nil
return
results
,
nil
}
}
...
@@ -216,7 +216,10 @@ func (j *JSONPath) evalArray(input []reflect.Value, node *ArrayNode) ([]reflect.
...
@@ -216,7 +216,10 @@ func (j *JSONPath) evalArray(input []reflect.Value, node *ArrayNode) ([]reflect.
for
_
,
value
:=
range
input
{
for
_
,
value
:=
range
input
{
value
,
isNil
:=
template
.
Indirect
(
value
)
value
,
isNil
:=
template
.
Indirect
(
value
)
if
isNil
||
(
value
.
Kind
()
!=
reflect
.
Array
&&
value
.
Kind
()
!=
reflect
.
Slice
)
{
if
isNil
{
continue
}
if
value
.
Kind
()
!=
reflect
.
Array
&&
value
.
Kind
()
!=
reflect
.
Slice
{
return
input
,
fmt
.
Errorf
(
"%v is not array or slice"
,
value
.
Type
())
return
input
,
fmt
.
Errorf
(
"%v is not array or slice"
,
value
.
Type
())
}
}
params
:=
node
.
Params
params
:=
node
.
Params
...
@@ -404,7 +407,7 @@ func (j *JSONPath) evalFilter(input []reflect.Value, node *FilterNode) ([]reflec
...
@@ -404,7 +407,7 @@ func (j *JSONPath) evalFilter(input []reflect.Value, node *FilterNode) ([]reflec
value
,
_
=
template
.
Indirect
(
value
)
value
,
_
=
template
.
Indirect
(
value
)
if
value
.
Kind
()
!=
reflect
.
Array
&&
value
.
Kind
()
!=
reflect
.
Slice
{
if
value
.
Kind
()
!=
reflect
.
Array
&&
value
.
Kind
()
!=
reflect
.
Slice
{
return
input
,
fmt
.
Errorf
(
"%v is not array or slice"
,
value
)
return
input
,
fmt
.
Errorf
(
"%v is not array or slice
and cannot be filtered
"
,
value
)
}
}
for
i
:=
0
;
i
<
value
.
Len
();
i
++
{
for
i
:=
0
;
i
<
value
.
Len
();
i
++
{
temp
:=
[]
reflect
.
Value
{
value
.
Index
(
i
)}
temp
:=
[]
reflect
.
Value
{
value
.
Index
(
i
)}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment