toJSON
builtins.toJSON
Primop
Docs pulled from | This Revision | about 11 hours ago
Nix manual
Takes 1 arguments
e
Return a string containing a JSON representation of e. Strings, integers, floats, booleans, nulls and lists are mapped to their JSON equivalents. Sets (except derivations) are represented as objects. Derivations are translated to a JSON string containing the derivation’s output path. Paths are copied to the store and represented as a JSON string of the resulting store path.
Noogle detected
Detected Type
toJSON :: a -> String
Implementation
This function is implemented in c++ and is part of the native nix runtime.
static void prim_toJSON(EvalState & state, const PosIdx pos, Value ** args, Value & v)
{
std::ostringstream out;
NixStringContext context;
printValueAsJSON(state, true, *args[0], pos, out, context);
v.mkString(out.view(), context, state.mem);
}