Skip to content

Commit

Permalink
Revert "Practise json. (#36)"
Browse files Browse the repository at this point in the history
This reverts commit e690c3d.
  • Loading branch information
hcsp-bot committed Jul 28, 2019
1 parent e690c3d commit 07482d2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 48 deletions.
5 changes: 0 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@
<version>5.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
</dependencies>

<build>
Expand Down
16 changes: 3 additions & 13 deletions src/main/java/com/github/hcsp/encapsulation/Main.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.github.hcsp.encapsulation;

import com.alibaba.fastjson.JSON;

public class Main {
/*
假设你正在为学校开发一个学生分数记录系统
Expand All @@ -27,16 +25,8 @@ public static void main(String[] args) {

student = deserialize(json);
}
// String text = JSON.toJSONString(obj); //序列化
// VO vo = JSON.parseObject("{...}", VO.class); //反序列化

// 序列化:将Student类转换成JSON字符串
public static String serialize(Student student) {
return JSON.toJSONString(student);
}

public static String serialize(Student student) {}
// 反序列化:将JSON字符串转换成Student对象
public static Student deserialize(String json) {
return JSON.parseObject(json, Student.class);
}
}
public static Student deserialize(String json) {}
}
30 changes: 0 additions & 30 deletions src/main/java/com/github/hcsp/encapsulation/Student.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,4 @@ public class Student {

/** 分数 */
private int score;

/** 是否挂科 **/
private boolean fail;

// 定义 Getter 和 Setter
public String getName() {
return name;
}
public Student setName(String name) {
this.name = name;
return this;
}
public boolean isRetakingExam() {
return retakingExam;
}
public Student setRetakingExam(boolean retakingExam) {
this.retakingExam = retakingExam;
return this;
}
public int getScore() {
return score;
}
public Student setScore(int score) {
this.score = score;
this.fail = score < 60;
return this;
}
public boolean isFail() {
return fail;
}
}

0 comments on commit 07482d2

Please sign in to comment.