Java: Compress JSON String

Create compact JSON string from beautified JSON string

1
2
3
4
5
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.JsonNode;

var jsonNode = new ObjectMapper().readValue(longJsonString, JsonNode.class);
String compressedJsonString = jsonNode.toString();