本文整理匯總了Java中me.hao0.common.json.Jsons類的典型用法代碼示例。如果您正苦於以下問題:Java Jsons類的具體用法?Java Jsons怎麽用?Java Jsons使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Jsons類屬於me.hao0.common.json包,在下文中一共展示了Jsons類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: serialize
import me.hao0.common.json.Jsons; //導入依賴的package包/類
@Override
public String serialize(Object o) {
try {
return Jsons.DEFAULT.toJson(o);
} catch (Exception e) {
log.error("failed to serialize http session {} to json,cause:{}", o, Throwables.getStackTraceAsString(e));
throw new SerializeException("failed to serialize http session to json", e);
}
}
示例2: deserialize
import me.hao0.common.json.Jsons; //導入依賴的package包/類
@Override
public Map<String,Object> deserialize(String o) {
try {
return Jsons.DEFAULT.fromJson(o, MAP_TYPE);
} catch (Exception e) {
log.error("failed to deserialize string {} to http session,cause:{} ", o, Throwables.getStackTraceAsString(e));
throw new SerializeException("failed to deserialize string to http session", e);
}
}
示例3: renderCount
import me.hao0.common.json.Jsons; //導入依賴的package包/類
private BillCount renderCount(String countData) {
// remove first `
countData = countData.substring(1).replaceAll("\\r", "");
String[] fieldVals = countData.split(FIELD_SEPARATOR);
Map<String, Object> billCount = new HashMap<>();
List<String> fieldNames = BillFields.COUNT;
for (int i = 0; i<fieldNames.size(); i++){
billCount.put(fieldNames.get(i), fieldVals[i]);
}
return Jsons.DEFAULT.fromJson(Jsons.DEFAULT.toJson(billCount), BillCount.class);
}
示例4: renderBill
import me.hao0.common.json.Jsons; //導入依賴的package包/類
private <T extends Bill> T renderBill(String dataLine, List<String> fieldNames, Class<T> billClazz) {
// remove first `
dataLine = dataLine.substring(1).replaceAll("\\r", "");
String[] fieldVals = dataLine.split(FIELD_SEPARATOR);
Map<String, Object> billData = new HashMap<>();
for (int i = 0; i<fieldNames.size(); i++){
billData.put(fieldNames.get(i), fieldVals[i]);
}
return Jsons.DEFAULT.fromJson(Jsons.DEFAULT.toJson(billData), billClazz);
}
示例5: doHttpsPost
import me.hao0.common.json.Jsons; //導入依賴的package包/類
protected <T> T doHttpsPost(final String url, final Map<String, String> params, Class<T> respClazz){
String requestBody = Maps.toXml(params);
String resp = Https.post(url).body(requestBody)
.ssLSocketFactory(wepay.getSslSocketFactory()).request();
Map<String, Object> respMap = toMap(resp.replaceAll("(\\r|\\n)", ""));
if (!doVerifySign(respMap)){
throw new SignException("微信響應內容簽名非法: " + respMap);
}
return Jsons.DEFAULT.fromJson(Jsons.DEFAULT.toJson(respMap), respClazz);
}
示例6: doQueryOrder
import me.hao0.common.json.Jsons; //導入依賴的package包/類
private WePayOrder doQueryOrder(Map<String, String> queryParams) {
buildQueryParams(queryParams);
Map<String, Object> orderData = doPost(ORDER_QUERY, queryParams);
WePayOrder order = Jsons.DEFAULT.fromJson(Jsons.DEFAULT.toJson(orderData), WePayOrder.class);
setCoupons(order, orderData);
return order;
}