- 开发一个接口,确保http://192.168.37.184:10103/demo3的Get请示返回
{ "code":0, "data":[{"stu_num":1, "stu_name": "张三"},{"stu_num":2, "stu_name": "李四"}], "msg":"" }
- 新建一个目录,如D:\pb_project\tutorial\p022_dw_http
- File-New-Workspace-OK,选中D:\pb_project\tutorial\p022_dw_http,打开,文件名输入p022_dw_http,保存
- File-New-Target-Application-OK,Application Name输入p022_app,Finish
- 下载https://github.com/bondliu2020/pbidea 把100文件夹下的websuit.pbl和PbIdea.dll复制到p022_dw_http文件夹
- 关了所有子窗口,右键p022_app,Library List-Browse,选中刚才复制过来的websuit.pbl,Apply-OK
- File-New-DataWindow-Grid-OK-External-next
- 加2个字段stu_name,string;stu_num,number,再一直next,最后保存为d_1
- 添加一个Windows,选中Windows,Insert-Control-DataWindow,在DataObject上选中刚才建的d_1,保存窗口为w_main
- 在w_main的open函数里输入
string as_url = "http://192.168.37.184:10103/demo3" string ls_str uo_curl u_curl u_curl = Create uo_curl u_curl.setUtf8(True) u_curl.SetTimeout(10000) u_curl.setUrl(as_url,"GET") boolean a a = u_curl.request("") uo_json json1 json1 = u_curl.response.json integer code uo_json data uo_json tmp data = Create uo_json tmp = Create uo_json //json1.get("code", code) json1.get("data", data) integer li_arrcount integer li_1 li_arrcount = data.arrcount( ) For li_1 = 0 To li_arrcount - 1 data.get( "/" + String(li_1) , tmp) integer stuNum string stuName tmp.get("stuNum", stuNum) tmp.get("stuName", stuName) dw_1.insertrow(0) dw_1.setitem(li_1 + 1, "stu_num", stuNum) dw_1.setitem(li_1 + 1, "stu_name",stuName) Next Destroy u_curl Destroy data Destroy tmp
- 在p022_app里输入open(w_main)