UE4 WCF RestFul 服务器 读取JSON 数据并解析 简单实例
2016-01-15 11:38
836 查看
bool UWgtCpp_BaseMain::Http_readSortList() { auto temp_request = UNetAPI::createRequst(TEXT("http://localhost:59754/StudentService.svc/GetStudentList"), TEXT("GET")); temp_request->OnProcessRequestComplete().BindUObject(this, &UWgtCpp_BaseMain::OnArrSortListLoaded); temp_request->ProcessRequest(); return true; } void UWgtCpp_BaseMain::OnArrSortListLoaded(FHttpRequestPtr _request, FHttpResponsePtr _response, bool bWasSuccessful) { UE_LOG(LogTemp, Warning, TEXT("OnArrSortListLoaded")); if (bWasSuccessful) { switch (_response->GetResponseCode()) { case 200: TArray<FDataCpp_BaseSortItem> arr; FJsonObjectConverter::JsonArrayStringToUStruct<FDataCpp_BaseSortItem>(_response->GetContentAsString(), &arr, 0,0); for (auto item : arr) { auto temp_str = FString::Printf(TEXT("%d , %s"),item.id , item.Name); GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Cyan, item.Name); } break; } } }
[OperationContract] [WebInvoke ( Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "GetStudentList" ) ] IList<Student> GetStudentList();
[{"Id":1,"Name":"sad"},{"Id":2,"Name":"ttt"},{"Id":3,"Name":"tretre"},{"Id":4,"Name":"terter"},{"Id":5,"Name":"treter"},{"Id":6,"Name":"fsdfds"},{"Id":7,"Name":"cccc"},{"Id":8,"Name":"vvvv"},{"Id":9,"Name":"bbb"},{"Id":10,"Name":"nnn"},{"Id":11,"Name":"mm"},{"Id":12,"Name":"qqq"},{"Id":13,"Name":"www"},{"Id":14,"Name":"eee"},{"Id":15,"Name":"rrr"},{"Id":16,"Name":"ttt"},{"Id":17,"Name":"yyy"},{"Id":18,"Name":"uuu"},{"Id":19,"Name":"iii"},{"Id":20,"Name":"ooo"},{"Id":21,"Name":"ppp"},{"Id":22,"Name":"aaa"},{"Id":23,"Name":"sss"},{"Id":24,"Name":"ddd"},{"Id":25,"Name":"fff"}]
相关文章推荐
- RabbitMQ入门教程 For Java【2】 - Work Queues
- 使用druid连接池的超时回收机制排查连接泄露问题
- Druid连接池一个设置引发的血案
- 最大团算法(Maximum Clique)
- UE4代码文件结构的正确配置
- ios中UIControl详解
- Cannot create type class java.io.File from value
- 深挖 NGUI 基础 之UIRoot (一)
- 检测到有潜在危险的 request.form 值
- Android酷炫实用的开源框架——UI框架(转)
- 导航条的使用 UINavigationBar
- 自定义UICollectionViewLayout 实现瀑布流
- String.valueOf() 方法的使用
- UGUI 动手制作字体
- easyui combobox 省市区 三级联动
- h2 DB的一个问题,关于类型--Numeric value out of range
- 多线程之NSOperation和NSOperationQueue
- UIWindow & UIWindowLevel详解
- UILabel宽度固定, 字体大小自适应
- Chapter9-3.Interrupt handling schemes 《ARM system developer's guide》