@@ -617,22 +617,23 @@ func compilePath(path []string) (out valuePath, _ error) {
617617 for i := range path {
618618 part := path [i ]
619619
620- if part == "[*]" {
621- // wildcard: retourner tous les éléments d'un array
622- out = append (out , pathOp {
623- part : part ,
624- op : func (m interface {}) interface {} {
625- if s , ok := m .([]interface {}); ok {
626- return s
627- }
628- return nil
629- },
630- })
631- continue
632- }
633-
634620 if strings .HasPrefix (part , "[" ) && strings .HasSuffix (part , "]" ) {
635621
622+ // Wildcard with filter: [*]
623+ if part == "[*]" {
624+ // function to return all elements in a list
625+ out = append (out , pathOp {
626+ part : part ,
627+ op : func (m interface {}) interface {} {
628+ if s , ok := m .([]interface {}); ok {
629+ return s
630+ }
631+ return nil
632+ },
633+ })
634+ continue
635+ }
636+
636637 // list lookup: [key=value]
637638 eq := strings .SplitN (part [1 :len (part )- 1 ], "=" , 2 )
638639 if len (eq ) != 2 {
@@ -677,7 +678,6 @@ func compilePath(path []string) (out valuePath, _ error) {
677678 } else {
678679 out = append (out , pathOp {
679680 part : part ,
680- // Function qui sera utilisé dans le Get pour descendre dans l'arborescence (op.op(obj))
681681 op : func (m interface {}) interface {} {
682682 // On cherche du clé valeur dans une map
683683 if mp , ok := m .(map [string ]interface {}); ok {
@@ -692,8 +692,6 @@ func compilePath(path []string) (out valuePath, _ error) {
692692 }
693693 }
694694 return mp [part ]
695- // On va checher un index dans une liste
696- // ex: [0], [1], ... -> on pourrait ici faire le boulot si *
697695 } else if s , ok := m .([]interface {}); ok {
698696 i , err := strconv .Atoi (part )
699697 if err != nil {
0 commit comments