Skip to content

Commit 04bf849

Browse files
committed
better support for []interface{}
1 parent 10bc4a8 commit 04bf849

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

dfl/Extract.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ func Extract(path string, obj interface{}) (interface{}, error) {
155155
return o[start:end], nil
156156
case *reader.Cache:
157157
return o.ReadRange(start, end-1)
158+
case []interface{}:
159+
if len(remainder) > 0 {
160+
return Extract(remainder, o[start:end])
161+
}
162+
return o[start:end], nil
158163
case []map[interface{}]interface{}:
159164
if len(remainder) > 0 {
160165
return Extract(remainder, o[start:end])
@@ -185,6 +190,11 @@ func Extract(path string, obj interface{}) (interface{}, error) {
185190
return o[start:], nil
186191
case *reader.Cache:
187192
return make([]byte, 0), errors.New("Reader cannot evaluate [start:]")
193+
case []interface{}:
194+
if len(remainder) > 0 {
195+
return Extract(remainder, o[start:])
196+
}
197+
return o[start:], nil
188198
case []map[interface{}]interface{}:
189199
if len(remainder) > 0 {
190200
return Extract(remainder, o[start:])
@@ -226,6 +236,11 @@ func Extract(path string, obj interface{}) (interface{}, error) {
226236
return make([]byte, 0), err
227237
}
228238
return values[0], nil
239+
case []interface{}:
240+
if len(remainder) > 0 {
241+
return Extract(remainder, o[slice_index])
242+
}
243+
return o[slice_index], nil
229244
case []map[interface{}]interface{}:
230245
if len(remainder) > 0 {
231246
return Extract(remainder, o[slice_index])

dfl/dfl.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
//
5151
// Projects
5252
//
53-
// go-dfl is used by the go-osm project.
53+
// go-dfl is used by the railgun and go-osm project.
54+
// - https://godoc.org/github.com/spatialcurrent/railgun/railgun
5455
// - https://godoc.org/github.com/spatialcurrent/go-osm/osm
5556
// - https://godoc.org/github.com/spatialcurrent/go-dfl/dfl
5657
//

0 commit comments

Comments
 (0)