Skip to content

Commit

Permalink
修复 Json 提交 Bean 类参数被解析成 String 类型的 Bug
Browse files Browse the repository at this point in the history
  • Loading branch information
getActivity committed Nov 8, 2021
1 parent 87bd11b commit 4448f98
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

* 博客地址:[网络请求,如斯优雅](https://www.jianshu.com/p/93cd59dec002)

* [点击此处下载Demo](https://github.com/getActivity/EasyHttp/releases/download/10.5/EasyHttp.apk)
* * 可以扫码下载 Demo 进行演示或者测试,如果扫码下载不了的,[点击此处下载Demo](https://github.com/getActivity/EasyHttp/releases/download/10.6/EasyHttp.apk)

![](picture/demo_code.png)

Expand Down Expand Up @@ -54,7 +54,7 @@ android {
dependencies {
// 网络请求框架:https://github.com/getActivity/EasyHttp
implementation 'com.github.getActivity:EasyHttp:10.5'
implementation 'com.github.getActivity:EasyHttp:10.6'
// OkHttp 框架:https://github.com/square/okhttp
// noinspection GradleDependency
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
Expand All @@ -67,7 +67,7 @@ dependencies {

| 功能或细节 | [EasyHttp](https://github.com/getActivity/EasyHttp) | [Retrofit](https://github.com/square/retrofit) | [OkGo](https://github.com/jeasonlzy/okhttp-OkGo) |
| :----: | :------: | :-----: | :-----: |
| 对应版本 | 10.5 | 2.9.0 | 3.0.4 |
| 对应版本 | 10.6 | 2.9.0 | 3.0.4 |
| issues 数 | [![](https://img.shields.io/github/issues/getActivity/EasyHttp.svg)](https://github.com/getActivity/EasyHttp/issues) | [![](https://img.shields.io/github/issues/square/retrofit.svg)](https://github.com/square/retrofit/issues) | [![](https://img.shields.io/github/issues/jeasonlzy/okhttp-OkGo.svg)](https://github.com/jeasonlzy/okhttp-OkGo/issues) |
| **aar 包大小** | 78 KB | 123 KB | 131 KB |
| minSdk 要求 | API 14+ | API 21+ | API 14+ |
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
applicationId 'com.hjq.easy.demo'
minSdkVersion 16
targetSdkVersion 31
versionCode 1050
versionName '10.5'
versionCode 1060
versionName '10.6'
}

// 支持 JDK 1.8
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ android {

defaultConfig {
minSdkVersion 14
versionCode 1050
versionName "10.5"
versionCode 1060
versionName "10.6"
}

// 使用 JDK 1.8
Expand Down
5 changes: 4 additions & 1 deletion library/src/main/java/com/hjq/http/EasyUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,9 @@ public static HashMap<String, Object> beanToHashMap(Object object) {
return data;
}

/**
* 对象转换
*/
public static Object convertObject(Object object) {
if (object instanceof List) {
// 如果这是一个 List 参数
Expand All @@ -288,7 +291,7 @@ public static Object convertObject(Object object) {
return String.valueOf(object);
} else if (isBeanType(object)) {
// 如果这是一个 Bean 参数
return beanToHashMap(object);
return mapToJsonObject(beanToHashMap(object));
} else {
// 如果这是一个普通的参数
return object;
Expand Down

0 comments on commit 4448f98

Please sign in to comment.