For a dockerfile like:
FROM alpine:latest
ENV VAR='{"example": "multi\nline\n"}'
RUN apk add jq
something like:
$ echo "${VAR}" | jq -c . > example.json
$ cat example.json
{"example":"multi\nline\n"}
would work. The -c
just disables the pretty print jq
does by default.