-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGSONBaseExample.java
More file actions
44 lines (36 loc) · 907 Bytes
/
GSONBaseExample.java
File metadata and controls
44 lines (36 loc) · 907 Bytes
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
package example.TmpExample;
/**
* GSON 可能要移轉到 spring boot 專案上
*
*
* Reference:
* - https://blog.tonycube.com/2012/03/gsonjavajson.html
* - https://github.com/google/gson/blob/master/UserGuide.md
*/
public class GSONBaseExample {
public static void main(String[] args) {
object2Json();
}
public static void object2Json() {
Book book = new Book("956-987236-1", "Java歷險記", 550);
System.out.println(book.toString());
}
public static void json2Object() {
}
}
class Book {
private String name;
private String isbn;
private int price;
Book(String name, String isbn, int price) {
this.name = name;
this.isbn = isbn;
this.price = price;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}