@@ -544,20 +544,27 @@ export class Parser {
544544 const props = [ ] as ObjectPropertyInfo [ ] ;
545545 for ( let i = 0 ; i < keyValueTokens . length ; i ++ ) {
546546 const keyValue = splitTokens ( keyValueTokens [ i ] , ':' ) ;
547- if ( keyValue . length !== 2 ) {
547+ if ( keyValue . length === 1 ) {
548+ const pInfo = {
549+ name : new ConstNode ( keyValue [ 0 ] [ 0 ] ) ,
550+ value : this . createExpressionNode ( keyValue [ 0 ] )
551+ } as ObjectPropertyInfo ;
552+
553+ props . push ( pInfo ) ;
554+ } else if ( keyValue . length === 2 ) {
555+ // unquoted string becomes a variable, so, we don't need it, that is why we are creating const node explicitlely
556+ const name = ( keyValue [ 0 ] . length === 1 && ! `'"` . includes ( ( getTokenValue ( keyValue [ 0 ] [ 0 ] ) as string ) [ 0 ] ) )
557+ ? new ConstNode ( keyValue [ 0 ] [ 0 ] )
558+ : this . createExpressionNode ( keyValue [ 0 ] ) ;
559+ const pInfo = {
560+ name,
561+ value : this . createExpressionNode ( keyValue [ 1 ] )
562+ } as ObjectPropertyInfo ;
563+
564+ props . push ( pInfo ) ;
565+ } else {
548566 throw Error ( 'Incorrect JSON' )
549567 }
550-
551- // unquoted string becomes a variable, so, we don't need it, that is why we are creating const node explicitlely
552- const name = ( keyValue [ 0 ] . length === 1 && ! `'"` . includes ( ( getTokenValue ( keyValue [ 0 ] [ 0 ] ) as string ) [ 0 ] ) )
553- ? new ConstNode ( keyValue [ 0 ] [ 0 ] )
554- : this . createExpressionNode ( keyValue [ 0 ] ) ;
555- const pInfo = {
556- name,
557- value : this . createExpressionNode ( keyValue [ 1 ] )
558- } as ObjectPropertyInfo ;
559-
560- props . push ( pInfo ) ;
561568 }
562569
563570 return new CreateObjectNode ( props , getTokenLoc ( tokens [ 0 ] ) )
0 commit comments