From 42758507b606e5d0e3d41a3fd40d3c7d9826287d Mon Sep 17 00:00:00 2001 From: h7x4 Date: Mon, 28 Nov 2022 20:23:03 +0100 Subject: [PATCH] json2nix: fix string quotation bug --- internals/json2nix/json2nix.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internals/json2nix/json2nix.hs b/internals/json2nix/json2nix.hs index debdf34..323fd4c 100644 --- a/internals/json2nix/json2nix.hs +++ b/internals/json2nix/json2nix.hs @@ -38,6 +38,6 @@ json2Nix (A.Number n) = T.pack $ show n json2Nix (A.Bool False) = "false" json2Nix (A.Bool True) = "true" json2Nix A.Null = "null" -json2Nix (A.String text) = T.concat [sep, text, sep] - where - sep = if "\"" `T.isInfixOf` text then "\'\'" else "\"" +-- Nixfmt will handle which quotation mark we are using anyway, so we +-- might as well just escape all "s and use them as string markers. +json2Nix (A.String text) = T.concat ["\"", T.replace "\"" "\\\"" text, "\""]