如何反序列化json集合

如何反序列化json集合

本文介绍了如何反序列化json集合。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何反序列化json集合。



{成功:true,data:{game_id:1,game_name:测试游戏,game_owner_id:1,host_id:1,host_name:测试主机,variant_id:1,variant_name:DeskTop,mode:demoplay,host_game_id:1 ,host_game_display_name:测试主机游戏,host_interface_id:1,host_interface_name:测试接口名称,参数:{host_parameters:[{parameter_id:1,parameter_name:测试基本参数,parameter_value:主机参数值,currency_code:INR}],game_parameters:[{parameter_id:1,parameter_name:测试基准参数,parameter_value: 游戏参数值,currency_code:INR},{parameter_id:2,parameter_name:测试参数,parameter_value:ffffsss,currency_code:INR}]} ,游戏:测试游戏,主持人:测试主机,变体:DeskTop},消息:游戏成功检索}



我尝试过:



动态东西= JsonConvert.DeserializeObject(jsondata); 
string str = stuff.success +< br> + stuff.data.game_id +< br> + stuff.data.game_name +< br> + stuff.data.variant_name +< br> + stuff.message +< br> + stuff.data.game_owner_id +< br> + stuff.data.host_id +< br> + stuff.data.host_name +< br> + stuff.data.variant_id +< br> + stuff.data.variant_name +< br> + stuff.data.mode +< br> + stuff.data.host_game_id +< br> + stuff.data.host_game_display_name +< br> + stuff.data.host_interface_id +< br> + stuff.data.host_interface_name;
Response.Write(str);

但是当我尝试从
参数获取数据时我卡住了:{host_parameters:[{parameter_id:1,parameter_name:测试基准参数, parameter_value:主机参数值,currency_code:INR}]
此部分。
解决方案



How to deserialize json collection.

{"success":true,"data":{"game_id":1,"game_name":"Test Game","game_owner_id":1,"host_id":1,"host_name":"Test Host","variant_id":1,"variant_name":"DeskTop","mode":"demoplay","host_game_id":1,"host_game_display_name":"Test Host Game","host_interface_id":1,"host_interface_name":"Test Interface Name","parameters":{"host_parameters":[{"parameter_id":1,"parameter_name":"Test Base Parameter","parameter_value":"Host param value","currency_code":"INR"}],"game_parameters":[{"parameter_id":1,"parameter_name":"Test Base Parameter","parameter_value":"Game param value","currency_code":"INR"},{"parameter_id":2,"parameter_name":"Test Base Parameter","parameter_value":"ffffsss","currency_code":"INR"}]},"game":"Test Game","host":"Test Host","variant":"DeskTop"},"message":"Games retrieved successfully"}

What I have tried:

 dynamic stuff = JsonConvert.DeserializeObject(jsondata);
            string str = stuff.success + "<br>" + stuff.data.game_id + "<br>" + stuff.data.game_name + "<br>" + stuff.data.variant_name + "<br>" + stuff.message + "<br>" + stuff.data.game_owner_id + "<br>" + stuff.data.host_id + "<br>" + stuff.data.host_name + "<br>" + stuff.data.variant_id + "<br>" + stuff.data.variant_name + "<br>" + stuff.data.mode + "<br>" + stuff.data.host_game_id + "<br>" + stuff.data.host_game_display_name + "<br>" + stuff.data.host_interface_id + "<br>" + stuff.data.host_interface_name ;
            Response.Write(str);

but i am stuck when i try to get data from
"parameters":{"host_parameters":[{"parameter_id":1,"parameter_name":"Test Base Parameter","parameter_value":"Host param value","currency_code":"INR"}]
 this section.
解决方案



这篇关于如何反序列化json集合。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 04:16