@@ -922,32 +922,35 @@ var jsonata = (function() {
922
922
var pair = expr . lhs [ pairIndex ] ;
923
923
var key = yield * evaluate ( pair [ 0 ] , reduce ? item [ '@' ] : item , env ) ;
924
924
// key has to be a string
925
- if ( typeof key !== 'string' ) {
925
+ if ( typeof key !== 'string' && key !== undefined ) {
926
926
throw {
927
927
code : "T1003" ,
928
928
stack : ( new Error ( ) ) . stack ,
929
929
position : expr . position ,
930
930
value : key
931
931
} ;
932
932
}
933
- var entry = { data : item , exprIndex : pairIndex } ;
934
- if ( groups . hasOwnProperty ( key ) ) {
935
- // a value already exists in this slot
936
- if ( groups [ key ] . exprIndex !== pairIndex ) {
937
- // this key has been generated by another expression in this group
938
- // when multiple key expressions evaluate to the same key, then error D1009 must be thrown
939
- throw {
940
- code : "D1009" ,
941
- stack : ( new Error ( ) ) . stack ,
942
- position : expr . position ,
943
- value : key
944
- } ;
945
- }
946
933
947
- // append it as an array
948
- groups [ key ] . data = fn . append ( groups [ key ] . data , item ) ;
949
- } else {
950
- groups [ key ] = entry ;
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
+ }
948
+
949
+ // append it as an array
950
+ groups [ key ] . data = fn . append ( groups [ key ] . data , item ) ;
951
+ } else {
952
+ groups [ key ] = entry ;
953
+ }
951
954
}
952
955
}
953
956
}
0 commit comments