use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class TypeUtilsTest method test_cast_to_BigDecimal.
public void test_cast_to_BigDecimal() throws Exception {
JSONObject json = new JSONObject();
json.put("id", 1);
Assert.assertEquals(new BigDecimal("1"), json.getObject("id", BigDecimal.class));
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class TypeUtilsTest method test_cast_to_Timestamp_util_Date.
public void test_cast_to_Timestamp_util_Date() throws Exception {
long millis = System.currentTimeMillis();
JSONObject json = new JSONObject();
json.put("date", new Date(millis));
Assert.assertEquals(new java.sql.Timestamp(millis), json.getObject("date", java.sql.Timestamp.class));
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class TypeUtilsTest method test_cast_to_Timestamp.
public void test_cast_to_Timestamp() throws Exception {
long millis = System.currentTimeMillis();
JSONObject json = new JSONObject();
json.put("date", millis);
Assert.assertEquals(new java.sql.Timestamp(millis), json.getObject("date", java.sql.Timestamp.class));
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class TypeUtilsTest method test_2.
public void test_2() throws Exception {
JSONObject map = new JSONObject();
map.put("id", 1);
map.put("name", "panlei");
User user = TypeUtils.castToJavaBean(map, User.class);
Assert.assertEquals(1L, user.getId());
Assert.assertEquals("panlei", user.getName());
}
use of com.alibaba.fastjson.JSONObject in project fastjson by alibaba.
the class TestUTF8 method test_utf_.
public void test_utf_() throws Exception {
String content = "Viel Spaß mit Java 7 und Eclipse!";
JSONObject json = new JSONObject();
json.put("content", content);
JSONObject obj = (JSONObject) JSON.parse(json.toJSONString().getBytes("UTF-8"));
Assert.assertEquals(1, obj.size());
Assert.assertEquals(content, obj.get("content"));
}
Aggregations