Browse Source

Bug im JSON parser bei kommazahlen behoben

Kolja Strohm 4 years ago
parent
commit
aac6ce3623
1 changed files with 15 additions and 1 deletions
  1. 15 1
      JSON.cpp

+ 15 - 1
JSON.cpp

@@ -415,8 +415,22 @@ JSONValue *Parser::getValue( const char *str )
         return new JSONArray( string );
     if( string.getText()[ 0 ] == '{' )
         return new JSONObject( string );
-    if( Text( (double)string ).istGleich( string.getText() ) )
+    if( Text( (int)string ).istGleich( string.getText() ) )
         return new JSONNumber( string );
+    if( string.anzahlVon( '.' ) )
+    {
+        Text *first = string.getTeilText( 0, string.positionVon( '.' ) );
+        Text *last = string.getTeilText( string.positionVon( '.' ) + 1 );
+        if( Text( (int)* first ).istGleich( first->getText() ) &&
+            Text( (int)* last ).istGleich( last->getText() ) )
+        {
+            first->release();
+            last->release();
+            return new JSONNumber( string );
+        }
+        first->release();
+        last->release();
+    }
     return new JSONValue();
 }