Refine search
/** * @return Formatted JSON representation of this StateMachine. May be provided to API calls (see {@link * com.amazonaws.services.stepfunctions.AWSStepFunctions}). */ public String toPrettyJson() { try { return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(this); } catch (JsonProcessingException e) { throw new SdkClientException("Could not serialize state machine.", e); } }
public String exportReportOverviewToJsonAsString(ReportOverview reportOverview) throws JsonProcessingException { return jsonMapper.writerWithDefaultPrettyPrinter().writeValueAsString(reportOverview); }
public static <T> String parseInPrettyMode(T obj) { try { return MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(obj); } catch (JsonProcessingException e) { Throwables.throwIfUnchecked(e); throw new IllegalArgumentException(e); } }
@Override public Optional<String> serializeExampleRequest(String serviceName, String methodName, Object exampleRequest) { try { return Optional.of(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(exampleRequest)); } catch (JsonProcessingException e) { // Ignore the exception and just return Optional.empty(). } return Optional.empty(); } }
@Override public TaskStatus apply(TaskStatus taskStatus) { try { log.info( "Task completed with status: %s", jsonMapper.writerWithDefaultPrettyPrinter().writeValueAsString(taskStatus) ); final File statusFileParent = statusFile.getParentFile(); if (statusFileParent != null) { FileUtils.forceMkdir(statusFileParent); } jsonMapper.writeValue(statusFile, taskStatus); return taskStatus; } catch (Exception e) { throw Throwables.propagate(e); } } }
@VisibleForTesting public String dumpJson() throws Exception { ObjectMapper jsonMapper = new ObjectMapper().registerModule( new MetricsModule(TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS, false)); return jsonMapper.writerWithDefaultPrettyPrinter().writeValueAsString(metricRegistry); }
public String serialize(MessageLogEntry messageLogEntry) { try { return objectMapper .writerWithDefaultPrettyPrinter() .writeValueAsString(messageLogEntry); } catch (Exception e) { mockServerLogger.error(String.format("Exception while serializing messageLogEntry to JSON with value %s", messageLogEntry), e); throw new RuntimeException(String.format("Exception while serializing messageLogEntry to JSON with value %s", messageLogEntry), e); } }
@VisibleForTesting public String dumpJson() throws Exception { ObjectMapper jsonMapper = new ObjectMapper() .registerModule(new MetricsModule(TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS, false)); return jsonMapper.writerWithDefaultPrettyPrinter().writeValueAsString(metricRegistry); }
public String serialize(LogEntry logEntry) { try { return objectMapper .writerWithDefaultPrettyPrinter() .writeValueAsString(logEntry); } catch (Exception e) { mockServerLogger.error(String.format("Exception while serializing LogEntry to JSON with value %s", logEntry), e); throw new RuntimeException(String.format("Exception while serializing LogEntry to JSON with value %s", logEntry), e); } }
public String serialize(PortBinding portBinding) { try { return objectMapper .writerWithDefaultPrettyPrinter() .writeValueAsString(portBinding); } catch (Exception e) { mockServerLogger.error(String.format("Exception while serializing portBinding to JSON with value %s", portBinding), e); throw new RuntimeException(String.format("Exception while serializing portBinding to JSON with value %s", portBinding), e); } }
private String serializedConfiguration(JsonNode config) throws JsonProcessingException{ ObjectMapper mapper = new ObjectMapper(); ObjectWriter writer = mapper.writerWithDefaultPrettyPrinter(); return config.isMissingNode() ? null : writer.writeValueAsString(config); }
/** Converts object to JSON string, throws runtime exception JsonWriteException on failure. */ public static String mapToFormattedJsonString( Object obj ) { try { return indentObjectMapper.writerWithDefaultPrettyPrinter().writeValueAsString( obj ); } catch ( Throwable t ) { if (logger.isDebugEnabled()) { logger.debug("Error generating JSON", t); } throw new JsonWriteException( "Error generating JSON", t ); } }
public String serialize(MessageLogEntry... messageLogEntries) { try { if (messageLogEntries != null && messageLogEntries.length > 0) { return objectMapper .writerWithDefaultPrettyPrinter() .writeValueAsString(messageLogEntries); } else { return "[]"; } } catch (Exception e) { mockServerLogger.error("Exception while serializing MessageLogEntry to JSON with value " + Arrays.asList(messageLogEntries), e); throw new RuntimeException("Exception while serializing MessageLogEntry to JSON with value " + Arrays.asList(messageLogEntries), e); } }
public String serialize(LogEntry... logEntries) { try { if (logEntries != null && logEntries.length > 0) { return objectMapper .writerWithDefaultPrettyPrinter() .writeValueAsString(logEntries); } else { return "[]"; } } catch (Exception e) { mockServerLogger.error("Exception while serializing LogEntry to JSON with value " + Arrays.asList(logEntries), e); throw new RuntimeException("Exception while serializing LogEntry to JSON with value " + Arrays.asList(logEntries), e); } }
public String serialize(HttpResponse httpResponse) { try { return objectMapper .writerWithDefaultPrettyPrinter() .writeValueAsString(new HttpResponseDTO(httpResponse)); } catch (Exception e) { mockServerLogger.error(String.format("Exception while serializing httpResponse to JSON with value %s", httpResponse), e); throw new RuntimeException(String.format("Exception while serializing httpResponse to JSON with value %s", httpResponse), e); } }
public String serialize(Expectation expectation) { try { return objectMapper .writerWithDefaultPrettyPrinter() .writeValueAsString(new ExpectationDTO(expectation)); } catch (Exception e) { mockServerLogger.error(String.format("Exception while serializing expectation to JSON with value %s", expectation), e); throw new RuntimeException(String.format("Exception while serializing expectation to JSON with value %s", expectation), e); } }
private String _jsonNodeToPrettyString(JsonNode jsonNode) throws ApioException { String json; try { ObjectWriter objectWriter = objectMapper.writerWithDefaultPrettyPrinter(); json = objectWriter.writeValueAsString(jsonNode); } catch (JsonProcessingException jpe) { if (_log.isDebugEnabled()) { _log.debug( "Unable to convert JsonNode to a String representation"); } throw new ApioException(jpe); } return json; }
public String serialize(VerificationSequence verificationSequence) { try { return objectMapper .writerWithDefaultPrettyPrinter() .writeValueAsString(new VerificationSequenceDTO(verificationSequence)); } catch (Exception e) { mockServerLogger.error("Exception while serializing verificationSequence to JSON with value " + verificationSequence, e); throw new RuntimeException("Exception while serializing verificationSequence to JSON with value " + verificationSequence, e); } }
public String serialize(Verification verification) { try { return objectMapper .writerWithDefaultPrettyPrinter() .writeValueAsString(new VerificationDTO(verification)); } catch (Exception e) { mockServerLogger.error("Exception while serializing verification to JSON with value " + verification, e); throw new RuntimeException("Exception while serializing verification to JSON with value " + verification, e); } }
public String serialize(boolean prettyPrint, HttpRequest httpRequest) { try { if (prettyPrint) { return objectMapper .writerWithDefaultPrettyPrinter() .writeValueAsString(new HttpRequestTemplateObject(httpRequest)); } else { return objectMapper .writerWithDefaultPrettyPrinter() .writeValueAsString(new HttpRequestDTO(httpRequest)); } } catch (Exception e) { mockServerLogger.error(String.format("Exception while serializing HttpRequest to JSON with value %s", httpRequest), e); throw new RuntimeException(String.format("Exception while serializing HttpRequest to JSON with value %s", httpRequest), e); } }