diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-02-15T13·46+0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-02-15T14·01+0100 |
commit | e03d6e09983bb5ad99352933c4d2f21b139294d2 (patch) | |
tree | f5c63799f982f66f1e6267fdc38930695835ce93 /src/libexpr | |
parent | eb62e23f14e953047938b05070e9dea730490b20 (diff) |
Fix broken number parsing in fromJSON
The call to tmp_number.append had its arguments mixed up. Also, JSON does not allow a trailing "," after array/object members.
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/json-to-value.cc | 7 |
1 files changed, 3 insertions, 4 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) { |