diff --git a/lix/libexpr/json-to-value.cc b/lix/libexpr/json-to-value.cc index 55aa5d374..81899d68a 100644 --- a/lix/libexpr/json-to-value.cc +++ b/lix/libexpr/json-to-value.cc @@ -190,13 +190,13 @@ public: } }; -void parseJSON(EvalState & state, const std::string_view & s_, Value & v) +Value parseJSON(EvalState & state, const std::string_view & s_) { JSONSax parser(state); bool res = JSON::sax_parse(s_, &parser); if (!res) throw JSONParseError("Invalid JSON Value"); - v = parser.result(); + return parser.result(); } } diff --git a/lix/libexpr/json-to-value.hh b/lix/libexpr/json-to-value.hh index ab66284a1..fc14b418b 100644 --- a/lix/libexpr/json-to-value.hh +++ b/lix/libexpr/json-to-value.hh @@ -12,6 +12,5 @@ struct Value; MakeError(JSONParseError, Error); -void parseJSON(EvalState & state, const std::string_view & s, Value & v); - +Value parseJSON(EvalState & state, const std::string_view & s); } diff --git a/lix/libexpr/primops.cc b/lix/libexpr/primops.cc index 1b0ce2b8e..2b3b8e302 100644 --- a/lix/libexpr/primops.cc +++ b/lix/libexpr/primops.cc @@ -1622,7 +1622,7 @@ static void prim_fromJSON(EvalState & state, Value * * args, Value & v) { auto s = state.forceStringNoCtx(*args[0], noPos, "while evaluating the first argument passed to builtins.fromJSON"); try { - parseJSON(state, s, v); + v = parseJSON(state, s); } catch (JSONParseError &e) { e.addTrace(nullptr, "while decoding a JSON string"); throw;