File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -421,8 +421,13 @@ private function parseJson(array $token)
421421 $ value = json_decode ($ token ['value ' ], true );
422422
423423 if ($ error = json_last_error ()) {
424- $ token ['type ' ] = self ::T_UNKNOWN ;
425- return $ token ;
424+ // Legacy support for elided quotes. Try to parse again by adding
425+ // quotes around the bad input value.
426+ $ value = json_decode ('" ' . $ token ['value ' ] . '" ' , true );
427+ if ($ error = json_last_error ()) {
428+ $ token ['type ' ] = self ::T_UNKNOWN ;
429+ return $ token ;
430+ }
426431 }
427432
428433 $ token ['value ' ] = $ value ;
Original file line number Diff line number Diff line change @@ -78,4 +78,12 @@ public function testTokenizesJsonNumbers()
7878 $ this ->assertEquals (120 , $ tokens [6 ]['value ' ]);
7979 $ this ->assertEquals ('2014-12 ' , $ tokens [8 ]['value ' ]);
8080 }
81+
82+ public function testCanWorkWithElidedJsonLiterals ()
83+ {
84+ $ l = new Lexer ();
85+ $ tokens = $ l ->tokenize ('`foo` ' );
86+ $ this ->assertEquals ('foo ' , $ tokens [0 ]['value ' ]);
87+ $ this ->assertEquals ('literal ' , $ tokens [0 ]['type ' ]);
88+ }
8189}
You can’t perform that action at this time.
0 commit comments