From cccd886cf0a9950a9f6cd8f1d116e637d1952285 Mon Sep 17 00:00:00 2001 From: "Dr. Ernie Prabhakar" <19791+drernie@users.noreply.github.com> Date: Sat, 21 Dec 2024 18:46:47 -0800 Subject: [PATCH] JSON via jackson.databind.ObjectWriter --- .../src/main/nextflow/quilt/jep/QuiltPackage.groovy | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy index 4db85cb5..1c19f6c8 100644 --- a/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy +++ b/plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy @@ -39,12 +39,15 @@ import com.quiltdata.quiltcore.key.LocalPhysicalKey import com.quiltdata.quiltcore.key.S3PhysicalKey import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.databind.ObjectWriter import com.fasterxml.jackson.databind.node.ObjectNode @Slf4j @CompileStatic class QuiltPackage { + private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper() + private static final ObjectWriter OBJECT_WRITER = OBJECT_MAPPER.writerWithDefaultPrettyPrinter() private static final Map PKGS = [:] private static final String INSTALL_PREFIX = 'QuiltPackage' static final Path INSTALL_ROOT = Files.createTempDirectory(INSTALL_PREFIX) @@ -83,11 +86,11 @@ class QuiltPackage { static String toJson(Map dict) { List entries = dict.collect { key, value -> - String prefix = JsonOutput.toJson(key) + String prefix = OBJECT_WRITER.writeValueAsString(key) log.debug("toJson.${key}: ${value}") String suffix = "toJson.error[${value}]" try { - suffix = JsonOutput.toJson(value) + suffix = OBJECT_WRITER.writeValueAsString(value) } catch (Exception e) { log.error(suffix, e)