Java Code Examples for com.fasterxml.jackson.core.JsonProcessingException#printStackTrace()

The following examples show how to use com.fasterxml.jackson.core.JsonProcessingException#printStackTrace() . 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: NewBlockHeightInvoke.java    From nuls-v2 with MIT License 5 votes vote down vote up
@Override
public void callBack(Response response) {
    try {
        LoggerUtil.commonLog.info("收到区块高度更新消息:{}", JSONUtils.obj2json(response));
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    HashMap result = ((HashMap) response.getResponseData());
    blockService.newBlockHeight(result);
}
 
Example 2
Source File: JacksonUtil.java    From SpringBootBucket with MIT License 5 votes vote down vote up
public static String bean2Json(Object obj) {
    try {
        return mapper.writeValueAsString(obj);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        return "";
    }
}
 
Example 3
Source File: ApiCallRcRestUtils.java    From linstor-server with GNU General Public License v3.0 5 votes vote down vote up
public static String toJSON(ApiCallRc apiCallRc)
{
    ObjectMapper objectMapper = new ObjectMapper();
    ArrayList<ApiCallData> jsonData = new ArrayList<>();

    for (ApiCallRc.RcEntry rc : apiCallRc.getEntries())
    {
        jsonData.add(new ApiCallData(
            rc.getReturnCode(),
            rc.getMessage(),
            rc.getCause(),
            rc.getCorrection(),
            rc.getDetails(),
            rc.getObjRefs(),
            rc.getErrorIds()
        ));
    }

    String ret = null;
    try
    {
        ret = objectMapper.writeValueAsString(jsonData);
    }
    catch (JsonProcessingException exc)
    {
        exc.printStackTrace();
    }

    return ret;
}
 
Example 4
Source File: JsonUtils.java    From sdb-mall with Apache License 2.0 5 votes vote down vote up
public static String toJson(Object obj) {
    try {
        return JSON.writeValueAsString(obj);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }

    return null;
}
 
Example 5
Source File: ApexCharts.java    From apexcharts-flow with Apache License 2.0 5 votes vote down vote up
/**
 * Method to set the data for all chart types except {@link com.github.appreciated.apexcharts.config.chart.Type#pie} and {@link com.github.appreciated.apexcharts.config.chart.Type#donut}.
 * For these both types use setSeries{@link #setSeries(Double[])}
 * @param series the data series to assign to the Chart
 */
public void setSeries(Series... series) {
    try {
        getModel().setSeries(objectMapper.writeValueAsString(series));
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
}
 
Example 6
Source File: MetricsResource.java    From robe with GNU Lesser General Public License v3.0 5 votes vote down vote up
@GET
@UnitOfWork(transactional = false, readOnly = true, flushMode = FlushMode.MANUAL)
public Response get(@RobeAuth Credentials credentials) {
    Response.ResponseBuilder builder = Response.ok();
    builder.status(Response.Status.ACCEPTED);
    try {
        builder.entity(OBJECT_MAPPER.writeValueAsString(environment.metrics()));
    } catch (JsonProcessingException e) {
        builder.status(Response.Status.INTERNAL_SERVER_ERROR);
        e.printStackTrace();
    }
    return builder.build();
}
 
Example 7
Source File: TimeRangeStreamingQuoteActionHandler.java    From ZStreamingQuote with MIT License 5 votes vote down vote up
/**
 * formatQuoteListToJSON - convert quote list to JSON
 * 
 * @param quote list
 * @return JSON formatted quote list
 */
private String formatQuoteListToJSON(List<StreamingQuote> quoteList) {
	String jsonData = null;
	ObjectMapper mapper = new ObjectMapper();

	try {
		jsonData = mapper.writeValueAsString(quoteList);
	} catch (JsonProcessingException e) {
		System.out.println(
				"TimeRangeStreamingQuoteActionHandler.formatQuoteListToJSON(): ERROR: JsonProcessingException on quote list !!!");
		e.printStackTrace();
	}

	return jsonData;
}
 
Example 8
Source File: JacksonUtil.java    From SpringBootBucket with MIT License 5 votes vote down vote up
public static String bean2Json(Object obj) {
    try {
        return mapper.writeValueAsString(obj);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        return null;
    }
}
 
Example 9
Source File: BeanUtil.java    From anyline with Apache License 2.0 5 votes vote down vote up
public static String object2json(Object obj){ 
	try {
		return JSON_MAPPER.writeValueAsString(obj);
	} catch (JsonProcessingException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example 10
Source File: JacksonUtil.java    From yshopmall with Apache License 2.0 5 votes vote down vote up
public static String toJson(Object data) {
    ObjectMapper objectMapper = new ObjectMapper();
    try {
        return objectMapper.writeValueAsString(data);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 11
Source File: JsonUtils.java    From Movie_Recommend with MIT License 5 votes vote down vote up
/**
   * 将对象转换成json字符串。
   * <p>Title: pojoToJson</p>
   * <p>Description: </p>
   * @param data
   * @return
   */
  public static String objectToJson(Object data) {
  	try {
	String string = MAPPER.writeValueAsString(data);
	return string;
} catch (JsonProcessingException e) {
	e.printStackTrace();
}
  	return null;
  }
 
Example 12
Source File: JsonUtil.java    From xmall with MIT License 5 votes vote down vote up
/**
   * 将对象转换成json字符串。
   */
  public static String objectToJson(Object data) {
  	try {
	String string = MAPPER.writeValueAsString(data);
	return string;
} catch (JsonProcessingException e) {
	e.printStackTrace();
}
  	return null;
  }
 
Example 13
Source File: JsonLoader.java    From calcite-test-dataset with Apache License 2.0 5 votes vote down vote up
public static void printJson(Object value) {
    try {
        System.out.println(new ObjectMapper().writeValueAsString(value));
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
}
 
Example 14
Source File: RatingCacheRepository.java    From tutorials with MIT License 5 votes vote down vote up
public boolean updateRating(Rating persisted) {
    try {
        valueOps.set("rating-" + persisted.getId(), jsonMapper.writeValueAsString(persisted));
        return true;
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    return false;
}
 
Example 15
Source File: BookControllerRestTemplateTest.java    From spring-boot with MIT License 5 votes vote down vote up
private static void printJSON(Object object) {
    String result;
    try {
        result = om.writerWithDefaultPrettyPrinter().writeValueAsString(object);
        System.out.println(result);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
}
 
Example 16
Source File: JacksonJsonLayoutTest.java    From log4j2-elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public ItemSource create(Object event, ObjectWriter objectWriter) {
    try {
        return new LayoutTestItemSource(objectWriter.writeValueAsString(event));
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
    return null;
}
 
Example 17
Source File: JsonNodeTypeHandler.java    From BigDataPlatform with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void setNonNullParameter(PreparedStatement ps, int i, JsonNode parameter, JdbcType jdbcType) throws SQLException {
    String str = null;
    try {
        str = mapper.writeValueAsString(parameter);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
        str = "{}";
    }
    ps.setString(i, str);
}
 
Example 18
Source File: LoggingTracer.java    From java-jaxrs with Apache License 2.0 5 votes vote down vote up
@Override
protected void onSpanFinished(MockSpan mockSpan) {
    try {
        String json = objectMapper.writeValueAsString(mockSpan);
        System.out.println(json);
    } catch (JsonProcessingException e) {
        e.printStackTrace();
    }
}
 
Example 19
Source File: JsonUtils.java    From train-ticket-reaper with MIT License 5 votes vote down vote up
/**
   * 
   * @Description:将对象转换成json字符串
   * @param data
   * @return
   * @author:Yeauty
   * @time:2017年8月18日 下午5:50:03
   */
  public static String objectToJson(Object data) {
  	try {
	String string = MAPPER.writeValueAsString(data);
	return string;
} catch (JsonProcessingException e) {
	e.printStackTrace();
}
  	return null;
  }
 
Example 20
Source File: DimensionalAlertGroupAuxiliaryRecipientProviderTest.java    From incubator-pinot with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreate() {
  Map<String, String> props = new HashMap<>();

  Map<DimensionMap, String> auxiliaryRecipients = new TreeMap<>();
  DimensionMap dimensionMap1 = new DimensionMap();
  dimensionMap1.put(GROUP_BY_DIMENSION_NAME, "V1");
  auxiliaryRecipients.put(dimensionMap1, EMAIL1);
  DimensionMap dimensionMap2 = new DimensionMap();
  dimensionMap2.put(GROUP_BY_DIMENSION_NAME, "V2");
  auxiliaryRecipients.put(dimensionMap2, EMAIL2);
  DimensionMap dimensionMap3 = new DimensionMap();
  dimensionMap3.put(GROUP_BY_DIMENSION_NAME, "V1");
  dimensionMap3.put("K2", "V3");
  auxiliaryRecipients.put(dimensionMap3, EMAIL_NOT_USED);

  try {
    ObjectMapper OBJECT_MAPPER = new ObjectMapper();
    String writeValueAsString = OBJECT_MAPPER.writeValueAsString(auxiliaryRecipients);
    props.put(DimensionalAlertGroupAuxiliaryRecipientProvider.AUXILIARY_RECIPIENTS_MAP_KEY, writeValueAsString);

    recipientProvider = new DimensionalAlertGroupAuxiliaryRecipientProvider();
    recipientProvider.setParameters(props);
    NavigableMap<DimensionMap, String> auxiliaryRecipientsRecovered = recipientProvider.getAuxiliaryEmailRecipients();

    // Test the map of auxiliary recipients
    Assert.assertEquals(auxiliaryRecipientsRecovered.get(dimensionMap1), EMAIL1);
    Assert.assertEquals(auxiliaryRecipientsRecovered.get(dimensionMap2), EMAIL2);
    Assert.assertEquals(auxiliaryRecipientsRecovered.get(dimensionMap3), EMAIL_NOT_USED);
  } catch (JsonProcessingException e) {
    e.printStackTrace();
    Assert.fail();
  }
}