fromJSON
builtins.fromJSON
Primop
Docs pulled from | This Revision | about 10 hours ago
Nix manual
Takes 1 arguments
e
Convert a JSON string to a Nix value. For example,
builtins.fromJSON ''{"x": [1, 2, 3], "y": null}''
returns the value { x = [ 1 2 3 ]; y = null; }.
Noogle detected
Detected Type
fromJSON :: String -> a
Implementation
This function is implemented in c++ and is part of the native nix runtime.
static void prim_fromJSON(EvalState & state, const PosIdx pos, Value ** args, Value & v)
{
auto s = state.forceStringNoCtx(*args[0], pos, "while evaluating the first argument passed to builtins.fromJSON");
try {
parseJSON(state, s, v);
} catch (JSONParseError & e) {
e.addTrace(state.positions[pos], "while decoding a JSON string");
throw;
}
}