From f70371559742c213d27d11cc4a39a13c73cec6ba Mon Sep 17 00:00:00 2001 From: zjz1993 <1429595365@qq.com> Date: Mon, 2 Sep 2019 18:04:18 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E9=92=88=E5=AF=B9pr=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=92=8C=E4=BF=AE=E6=94=B9=E3=80=82=E8=A1=A5?= =?UTF-8?q?=E5=85=85=E5=8D=95=E5=85=83=E6=B5=8B=E8=AF=95=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9javadoc=E6=8F=90=E7=A4=BA=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fanruan/api/err/JSONException.java | 10 +++++----- src/main/java/com/fanruan/api/json/JSONKit.java | 10 ++++++++++ .../java/com/fanruan/api/json/JSONKitTest.java | 15 +++++++++++++++ 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 src/test/java/com/fanruan/api/json/JSONKitTest.java diff --git a/src/main/java/com/fanruan/api/err/JSONException.java b/src/main/java/com/fanruan/api/err/JSONException.java index 393c32e..1abb13a 100644 --- a/src/main/java/com/fanruan/api/err/JSONException.java +++ b/src/main/java/com/fanruan/api/err/JSONException.java @@ -1,14 +1,14 @@ package com.fanruan.api.err; -/* -* 定义json的异常 -* */ +/** + * 用来定义和JSON相关的异常 + * */ public class JSONException extends com.fr.json.JSONException{ public JSONException(String message) { super(message); } - public JSONException(Throwable var1) { - super(var1); + public JSONException(Throwable error) { + super(error); } } diff --git a/src/main/java/com/fanruan/api/json/JSONKit.java b/src/main/java/com/fanruan/api/json/JSONKit.java index 2514012..86bdedf 100644 --- a/src/main/java/com/fanruan/api/json/JSONKit.java +++ b/src/main/java/com/fanruan/api/json/JSONKit.java @@ -2,9 +2,19 @@ package com.fanruan.api.json; import com.fr.json.JSONObject; public class JSONKit { + /** + * 创建一个JSONObject对象 + * + * @return 一个JSONObject对象 + */ public static JSONObject create() { return new JSONObject(); } + /** + * 创建一个JSONObject对象 + * @param text 用来创建对象时的字符串 + * @return 一个JSONObject对象 + */ public static JSONObject create(String text) { return new JSONObject(text); } diff --git a/src/test/java/com/fanruan/api/json/JSONKitTest.java b/src/test/java/com/fanruan/api/json/JSONKitTest.java new file mode 100644 index 0000000..32c4261 --- /dev/null +++ b/src/test/java/com/fanruan/api/json/JSONKitTest.java @@ -0,0 +1,15 @@ +package com.fanruan.api.json; +import com.fanruan.api.util.ArrayKit; +import com.fr.json.JSONObject; + +import org.junit.Assert; +import org.junit.Test; + +public class JSONKitTest { + @Test + public void create() throws Exception{ + Assert.assertEquals(JSONKit.create(), new JSONObject()); + Assert.assertEquals(JSONKit.create("{test:123}"), new JSONObject("{test:123}")); + + } +}