Comments (1)
这个不方便添加到 DevApp 库中,因为会依赖 Gson 且导致别人项目版本不一致,但是我有专门的 kotlin 库里面实现了。
// DevEngine - 第三方框架解耦、一键替换第三方库、同类库多 Engine 组件化混合使用
implementation 'io.github.afkt:DevEngine:1.0.8'
如何使用 Gson 可查看 json.kt 以下为使用示例:
// 初始化只需调用
DevEngine.completeInitialize(context)
// 假设存在 User 实体类
val user = User()
// 转换为 JSON 字符串
val json = user.toJson()
// 映射为实体类
val user1 = json.fromJson(
classOfT = User::class.java
)
// 上面是最简单常见的使用,下面还有其他方法
// 转换为 JSON 字符串并进行格式化缩进
val json = user.toJsonIndent()
// 判断字符串是否 JSON 格式
json.isJSON()
// 判断字符串是否 JSON Object 格式
json.isJSONObject()
// 判断字符串是否 JSON Array 格式
json.isJSONArray()
只要调用初始化 DevEngine.completeInitialize(context)
方法,无需考虑内部实现,默认使用 Gson 作为 JSON Engine 进行处理了。
from devutils.
Related Issues (20)
- 你没看错,我又来了 HOT 4
- 蓝牙相关工具类 HOT 1
- 关联库出错 HOT 3
- 能否出个android Q的文件存储操作等的适配 HOT 1
- 建议加一个 WorkManager 封装工具类 HOT 1
- 发现demo在使用DevEnvironment过程中会出现如下问题 ,华为8.10 10.0.0 都有这个报错信息 HOT 1
- DevEnvironment 的DevEnvironmentActivity 界面显示错误 HOT 1
- 请问坐标系工具类里面通过两点的坐标系计算距离这个功能,是在哪个坐标体系下进行计算的?谷歌的?还是火星坐标系?还是百度坐标系 HOT 1
- 请问坐标系工具类里面通过两点的坐标系计算距离这个功能,是在哪个坐标体系下进行计算的?谷歌的?还是火星坐标系?还是百度坐标系?
- 截图工具类 HOT 2
- 建议加上获取可运行app列表的API HOT 1
- DateUtils.isInTimeHHmmss("7:00","7:00") HOT 4
- 版本适配库 HOT 24
- ava.lang.Exception: Toast callstack! HOT 2
- 狗都不用
- AlarmUtils.java HOT 2
- DEV工具类,是否有清除缓存和计算缓存大小的方法? HOT 2
- AppUtils HOT 2
- 电池电量信息 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from devutils.