Skip to content

Commit

Permalink
Fixed issue #19
Browse files Browse the repository at this point in the history
  • Loading branch information
darronschall committed Apr 30, 2007
1 parent fe02e83 commit de24d26
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/com/adobe/serialization/json/JSONDecoder.as
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,13 @@ package com.adobe.serialization.json {
/**
* Attempt to parse a value
*/
private function parseValue():Object {
private function parseValue():Object
{
// Catch errors when the input stream ends abruptly
if ( token == null )
{
tokenizer.parseError( "Unexpected end of input" );
}

switch ( token.type ) {
case JSONTokenType.LEFT_BRACE:
Expand Down
17 changes: 17 additions & 0 deletions tests/com/adobe/serialization/json/JSONTest.as
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,23 @@ package com.adobe.serialization.json
}
assertEquals( 4, count );
}

public function testDecodeEmptyStringError():void
{
var e:Error = null;

try
{
JSON.decode( "" );
}
catch ( pe:JSONParseError )
{
e = pe;
}

assertNotNull( e );
assertTrue( "Caught parse error", e is JSONParseError );
}
}

}

0 comments on commit de24d26

Please sign in to comment.