接口返回数据格式问题

xuesong 4月前 190

{"code":1,"msg":"操作成功!","time":"1523546328","data":{"id":3,"user_id":3,"realname":"","idcard_number":"","hold_idcard_image":"","idcard_back_image":"","school_cert_image":"\/user","content":"","handle_time":"0000-00-00","expire_time":"0000-00-00","createtime":1523546323,"updatetime":1523546323,"examinetime":0,"status":"0","examinetime_text":"1970-01-01 08:00:00","status_text":"未审核"}}

这是返回的json格式数据,里面有int还有string类型,能不能在返回的时候data里面的数据处理一下,全部转为string类型,因为跟APP那边对接的时候,一个类型对应不起来APP就会崩溃。

{"code":1,"msg":"操作成功!","time":"1523546328","data":{"id":"3","user_id":"3","realname":"","idcard_number":"","hold_idcard_image":"","idcard_back_image":"","school_cert_image":"\/user","content":"","handle_time":"0000-00-00","expire_time":"0000-00-00","createtime":"1523546323","updatetime":"1523546323","examinetime":"0","status":"0","examinetime_text":"1970-01-01 08:00:00","status_text":"未审核"}}
最后于 3月前 被Karson编辑
最新回复 (2)
  • xuesong 楼主 4月前
    感谢TA
    0 引用 2

    还有就是data里面比如有null,也转为""

  • Karson 打赏 3月前
    感谢TA
    0 引用 3

    @xuesong 强制类型转换可以在模型中定放字段类型即可,这是TP5自带的功能。

  • 未登录
    4
返回