Java Jackson необязательно

ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new Jdk8Module());
String jsonString = mapper.writeValueAsString(optionalObject);
Outstanding Owl