-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJsonUtilsTest.java
More file actions
65 lines (54 loc) · 1.13 KB
/
Copy pathJsonUtilsTest.java
File metadata and controls
65 lines (54 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com;
import com.json.JsonUtils;
import com.bean.Person;
import net.sf.json.JSONObject;
import org.junit.Test;
import org.junit.Before;
import org.junit.After;
/**
* JsonUtils Tester.
*
* @author <Authors name>
* @since <pre>03/05/2018</pre>
* @version 1.0
*/
public class JsonUtilsTest {
private Person person1=new Person("feng","male",26);
@Before
public void before() throws Exception {
}
@After
public void after() throws Exception {
}
/**
*
* Method: objectToJson(Object object)
*
*/
@Test
public void testObjectToJson() throws Exception {
//TODO: Test goes here...
System.out.println( JsonUtils.objectToJson(person1) );
}
/**
*
* Method: listToJson(List<T> list)
*
*/
@Test
public void testListToJson() throws Exception {
//TODO: Test goes here...
}
/**
*
* Method: jsonToObject(JSONObject jsonObject, Class beanClass)
*
*/
@Test
public void testJsonToObject() throws Exception {
//TODO: Test goes here...
JSONObject jsonObject=JSONObject.fromObject(person1);
Person person= (Person)JSONObject.toBean(jsonObject,Person.class) ;
System.out.println(person.getAge());
}
}