about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/libexpr/json-to-value.cc7
-rw-r--r--tests/lang/eval-okay-fromjson.nix2
2 files changed, 4 insertions, 5 deletions
diff --git a/src/libexpr/json-to-value.cc b/src/libexpr/json-to-value.cc
index 7ef2b2c56227..1daf84600dca 100644
--- a/src/libexpr/json-to-value.cc
+++ b/src/libexpr/json-to-value.cc
@@ -113,14 +113,13 @@ static void parseJSON(EvalState & state, const char * & s, Value & v)
         while (isdigit(*s) || *s == '-' || *s == '.' || *s == 'e' || *s == 'E') {
             if (*s == '.' || *s == 'e' || *s == 'E')
                 number_type = tFloat;
-            tmp_number.append(*s++, 1);
+            tmp_number += *s++;
         }
 
-        if (number_type == tFloat) {
+        if (number_type == tFloat)
             mkFloat(v, stod(tmp_number));
-        } else {
+        else
             mkInt(v, stoi(tmp_number));
-        }
     }
 
     else if (strncmp(s, "true", 4) == 0) {
diff --git a/tests/lang/eval-okay-fromjson.nix b/tests/lang/eval-okay-fromjson.nix
index 2a9ad0cabeb0..102ee82b5e6b 100644
--- a/tests/lang/eval-okay-fromjson.nix
+++ b/tests/lang/eval-okay-fromjson.nix
@@ -14,7 +14,7 @@ builtins.fromJSON
           "Animated" : false,
           "IDs": [116, 943, 234, 38793, true  ,false,null, -100],
           "Latitude":  37.7668,
-          "Longitude": -122.3959,
+          "Longitude": -122.3959
         }
     }
   ''