Java Code Examples for com.cedarsoftware.util.io.JsonWriter#objectToJson()
The following examples show how to use
com.cedarsoftware.util.io.JsonWriter#objectToJson() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlowLogDBServiceTest.java From cloudbreak with Apache License 2.0 | 6 votes |
@Test public void updateLastFlowLogPayload() { FlowLog flowLog = new FlowLog(); flowLog.setId(ID); Payload payload = mock(Selectable.class); Map<Object, Object> variables = Map.of("repeated", 2); underTest.updateLastFlowLogPayload(flowLog, payload, variables); ArgumentCaptor<FlowLog> flowLogCaptor = ArgumentCaptor.forClass(FlowLog.class); verify(flowLogRepository, times(1)).save(flowLogCaptor.capture()); FlowLog savedFlowLog = flowLogCaptor.getValue(); assertEquals(flowLog.getId(), savedFlowLog.getId()); String payloadJson = JsonWriter.objectToJson(payload, Map.of()); String variablesJson = JsonWriter.objectToJson(variables, Map.of()); assertEquals(payloadJson, savedFlowLog.getPayload()); assertEquals(variablesJson, savedFlowLog.getVariables()); }
Example 2
Source File: FlowLogDBService.java From cloudbreak with Apache License 2.0 | 5 votes |
public String getSerializedString(Object object) { String objectAsString; try { objectAsString = JsonWriter.objectToJson(object, writeOptions); } catch (Exception e) { LOGGER.debug("Somehow can not serialize object to string, try another method..", e); objectAsString = JsonUtil.writeValueAsStringSilent(object); } return objectAsString; }
Example 3
Source File: FlowLogDBService.java From cloudbreak with Apache License 2.0 | 5 votes |
public void updateLastFlowLogPayload(FlowLog lastFlowLog, Payload payload, Map<Object, Object> variables) { String payloadJson = JsonWriter.objectToJson(payload, writeOptions); String variablesJson = JsonWriter.objectToJson(variables, writeOptions); Optional.ofNullable(lastFlowLog) .ifPresent(flowLog -> { flowLog.setPayload(payloadJson); flowLog.setVariables(variablesJson); flowLogRepository.save(flowLog); }); }
Example 4
Source File: JsonIO.java From marshalsec with MIT License | 4 votes |
@Override public String marshal ( Object o ) throws Exception { return JsonWriter.objectToJson(o); }
Example 5
Source File: AlgorithmObservedData.java From jMetalSP with MIT License | 4 votes |
@Override public String toJson() { return JsonWriter.objectToJson(this); }
Example 6
Source File: ObservedValue.java From jMetalSP with MIT License | 4 votes |
@Override public String toJson() { return JsonWriter.objectToJson(this); }
Example 7
Source File: ObservedSolution.java From jMetalSP with MIT License | 4 votes |
@Override public String toJson() { return JsonWriter.objectToJson(this); }
Example 8
Source File: ObservedDoubleSolutionList.java From jMetalSP with MIT License | 4 votes |
@Override public String toJson() { return JsonWriter.objectToJson(this) ; }
Example 9
Source File: ObservedDoubleSolution.java From jMetalSP with MIT License | 4 votes |
@Override public String toJson() { return JsonWriter.objectToJson(this) ; }
Example 10
Source File: ObservedIntegerValue.java From jMetalSP with MIT License | 4 votes |
@Override public String toJson() { return JsonWriter.objectToJson(this); }
Example 11
Source File: FlowLogDBService.java From cloudbreak with Apache License 2.0 | 4 votes |
public void saveChain(String flowChainId, String parentFlowChainId, Queue<Selectable> chain, String flowTriggerUserCrn) { String chainJson = JsonWriter.objectToJson(chain); FlowChainLog chainLog = new FlowChainLog(flowChainId, parentFlowChainId, chainJson, flowTriggerUserCrn); flowChainLogService.save(chainLog); }
Example 12
Source File: TestGraphComparator.java From java-util with Apache License 2.0 | 4 votes |
private Object clone(Object source) throws Exception { String json = JsonWriter.objectToJson(source); return JsonReader.jsonToJava(json); }