Commit beaab946 authored by David黄金龙's avatar David黄金龙

添加测试代码

parent 48876435
......@@ -139,6 +139,11 @@ class YHHomeViewController: YHBaseViewController {
//2.网络请求
requestData()
//for test hjl
// testModelParse()//for test hjl 添加 数据类型 转换
}
......@@ -150,6 +155,65 @@ class YHHomeViewController: YHBaseViewController {
// MARK: - 私有方法
extension YHHomeViewController {
func testModelParse() {
// SmartConfig.debugMode = .verbose
let json = """
{
"data": "balabala Team",
"errorCode": 0,
"errorMessage": "操作成功",
"success":true,
"test": {
"test1": "test1-value",
"test2": "test2-value",
"test333": "test3-value",
},
"testArr":[
{
"test1": "test1-value",
"test2": "test2-value",
"test333": "test3-value",
},
{
"test1": "test1-value",
"test2": "test2-value",
"test333": "test3-value",
},
{
"test1": "test1-value",
"test2": "test2-value",
"test333": "test3-value",
}
]
}
"""
//1. json字符串 转 对象
guard let model = NetBaseModel.deserialize(json: json) else { return }
print("model 是 ==>",model)
print(model)
//2. 对象 转 dictionary
let dic = model.toDictionary()
print("dic 是 ==>",dic as Any)
//3. dictionary 转 string
let jsonString = dic?.jsonString()
print("jsonString 是 ==>",jsonString ?? "")
//4.model 转 string
let jsonString2 = model.toJSONString()
print("jsonString2 是 ==>",jsonString2 ?? "")
//5. dic 转 model
guard let model1 = NetBaseModel.deserialize(dict: dic) else { return }
print("model1 是 ==>",model1)
}
@objc func leaveTopOp() {
canScroll = true
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment