use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Issue1063 method test_for_issue.
public void test_for_issue() throws Exception {
long currentMillis = System.currentTimeMillis();
TimestampBean bean = new TimestampBean();
bean.setTimestamp(new Timestamp(currentMillis));
String timestampJson = JSON.toJSONString(bean);
// 这里能转换成功
TimestampBean beanOfJSON = JSON.parseObject(timestampJson, TimestampBean.class);
// 这里抛异常 java.lang.NumberFormatException
JSONObject jsonObject = JSON.parseObject(timestampJson);
Timestamp timestamp2 = jsonObject.getObject("timestamp", Timestamp.class);
assertEquals(currentMillis / 1000, timestamp2.getTime() / 1000);
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Issue125 method test_for_issue.
public void test_for_issue() throws Exception {
String content = "{\"data\":\"sfasfasdfasdfas\\r" + String.valueOf((char) 160) + "\\rasdfasdfasd\"}";
JSONObject jsonObject = JSON.parseObject(content);
System.out.println(jsonObject);
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Issue126 method test_for_issue.
public void test_for_issue() throws Exception {
JSONObject j = new JSONObject();
j.put("content", "爸爸去哪儿-第十期-萌娃比赛小猪快跑 爸爸上演\"百变大咖秀\"-【湖南卫视官方版1080P】20131213: http://youtu.be/ajvaXKAduJ4 via @youtube");
System.out.println(j.toJSONString());
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Bug_for_jiangwei1 method test_double.
public void test_double() throws Exception {
JSONObject json = JSON.parseObject("{\"val\":12.3}");
Assert.assertTrue(12.3D == json.getDoubleValue("val"));
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class Issue157 method test_for_issue.
public void test_for_issue() throws Exception {
String m = "2、95开头靓号,呼出显号,对方可以打回,即使不在线亦可设置呼转手机,不错过任何重要电话,不暴露真实身份。\r\n3、应用内完全免费发送文字消息、语音对讲。\r\n4、建议WIFI 或 3G 环境下使用以获得最佳通话体验";
JSONObject json = new JSONObject();
json.put("介绍", m);
String content = json.toJSONString();
System.out.println(content);
}
Aggregations