From 00921f6e3cd4b8dcdd9be7cea81c52c86d9c0706 Mon Sep 17 00:00:00 2001 From: Farid Zakaria Date: Thu, 24 Jul 2025 20:43:02 -0700 Subject: [PATCH] Add support for stripping_comments from json. Update documentation of primop --- src/libexpr/json-to-value.cc | 3 ++- src/libexpr/primops.cc | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libexpr/json-to-value.cc b/src/libexpr/json-to-value.cc index 9c645e7fd..f2fb03569 100644 --- a/src/libexpr/json-to-value.cc +++ b/src/libexpr/json-to-value.cc @@ -204,7 +204,8 @@ public: void parseJSON(EvalState & state, const std::string_view & s_, Value & v) { JSONSax parser(state, v); - bool res = json::sax_parse(s_, &parser); + bool res = json::sax_parse( + s_, &parser, nlohmann::detail::input_format_t::json, /* strict= */ true, /* ignore_comments= */ true); if (!res) throw JSONParseError("Invalid JSON Value"); } diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index a645f546d..bafaccc83 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -2492,6 +2492,8 @@ static RegisterPrimOp primop_fromJSON({ ``` returns the value `{ x = [ 1 2 3 ]; y = null; }`. + + This function supports JSON with comments. )", .fun = prim_fromJSON, });