@@ -931,24 +931,26 @@ var jsonata = (function() {
931
931
} ;
932
932
}
933
933
934
- var entry = { data : item , exprIndex : pairIndex } ;
935
- if ( groups . hasOwnProperty ( key ) ) {
936
- // a value already exists in this slot
937
- if ( groups [ key ] . exprIndex !== pairIndex ) {
938
- // this key has been generated by another expression in this group
939
- // when multiple key expressions evaluate to the same key, then error D1009 must be thrown
940
- throw {
941
- code : "D1009" ,
942
- stack : ( new Error ( ) ) . stack ,
943
- position : expr . position ,
944
- value : key
945
- } ;
946
- }
934
+ if ( key !== undefined ) {
935
+ var entry = { data : item , exprIndex : pairIndex } ;
936
+ if ( groups . hasOwnProperty ( key ) ) {
937
+ // a value already exists in this slot
938
+ if ( groups [ key ] . exprIndex !== pairIndex ) {
939
+ // this key has been generated by another expression in this group
940
+ // when multiple key expressions evaluate to the same key, then error D1009 must be thrown
941
+ throw {
942
+ code : "D1009" ,
943
+ stack : ( new Error ( ) ) . stack ,
944
+ position : expr . position ,
945
+ value : key
946
+ } ;
947
+ }
947
948
948
- // append it as an array
949
- groups [ key ] . data = fn . append ( groups [ key ] . data , item ) ;
950
- } else {
951
- groups [ key ] = entry ;
949
+ // append it as an array
950
+ groups [ key ] . data = fn . append ( groups [ key ] . data , item ) ;
951
+ } else {
952
+ groups [ key ] = entry ;
953
+ }
952
954
}
953
955
}
954
956
}
@@ -965,7 +967,7 @@ var jsonata = (function() {
965
967
env = createFrameFromTuple ( environment , tuple ) ;
966
968
}
967
969
var value = yield * evaluate ( expr . lhs [ entry . exprIndex ] [ 1 ] , context , env ) ;
968
- if ( typeof value !== 'undefined' && key !== 'undefined' ) {
970
+ if ( typeof value !== 'undefined' ) {
969
971
result [ key ] = value ;
970
972
}
971
973
}
0 commit comments