1
0
mirror of https://github.com/h7x4/nix-attr-search.git synced 2024-12-22 03:57:32 +01:00

json2nix: fix string quotation bug

This commit is contained in:
Oystein Kristoffer Tveit 2022-11-28 20:23:03 +01:00
parent d30a1093a3
commit 42758507b6
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146

View File

@ -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, "\""]