Skip to content

Commit

Permalink
JSON via jackson.databind.ObjectWriter
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Dec 22, 2024
1 parent 9555bce commit cccd886
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String,QuiltPackage> PKGS = [:]
private static final String INSTALL_PREFIX = 'QuiltPackage'
static final Path INSTALL_ROOT = Files.createTempDirectory(INSTALL_PREFIX)
Expand Down Expand Up @@ -83,11 +86,11 @@ class QuiltPackage {

static String toJson(Map dict) {
List<String> 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)
Expand Down

0 comments on commit cccd886

Please sign in to comment.