加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 我如何将json字符串转换为Json对象

发布时间:2020-12-15 19:40:57 所属栏目:百科 来源:网络整理
导读:参见英文答案 Convert JSON String to JSON Object c#????????????????????????????????????7个 我有json字符串的方法,我想将json字符串转换为json对象.我试过下面的方法它显示内存超出如何解决错误. 我试过这个字符串抛出ajax它的工作正常.但我如何从后端的
参见英文答案 > Convert JSON String to JSON Object c#????????????????????????????????????7个
我有json字符串的方法,我想将json字符串转换为json对象.我试过下面的方法它显示内存超出如何解决错误.
我试过这个字符串抛出ajax它的工作正常.但我如何从后端的字符串转换为数据表.任何建议.
我的代码.

public ActionResult JosnString()
        {

      string str = "{"delivery": [{"status": 2,"resp_msg": "5.4.1 [renard.allenll@transdev.com]: Recipient address rejected: Access denied [HE1EUR02FT054.eop-EUR02.prod.protection.outlook.com]","mail_from": "vision@transdev.com","time_started": 1539808420,"time_finished": 1539808426,"resp_code_description": "The requested command failed because the user's mailbox was unavailable (for example because it was not found,or because the command was rejected for policy reasons).","sender_id": 9007074,"campaign_id": "","rcpt_to": "renard.allenll@transdev.com","tries": 0,"resp_code": 550,"tracking_id": "2939c3ea-59e8-4019-9f4b-4cd4214254b4","resp_class": 10,"subject": "Las Vegas Notification - Passenger Fall- No Injury (Auto Email u2013 Do Not Repl (#718701)"},{"status": 2,"resp_msg": "5.4.1 [Theodrick.mccullom@transdev.com]: Recipient address rejected: Access denied [HE1EUR02FT042.eop-EUR02.prod.protection.outlook.com]","time_started": 1539809940,"time_finished": 1539809944,"rcpt_to": "theodrick.mccullom@transdev.com","tracking_id": "2c75c0e1-cf9c-4c92-9d11-e6cebfc28300","subject": "Las Vegas Notification - Safety- Passenger Event (Auto Email u2013 Do Not Reply) (#724957)"},"resp_msg": "5.4.1 [tricia.mumford@transdev.com]: Recipient address rejected: Access denied [VE1EUR02FT003.eop-EUR02.prod.protection.outlook.com]","time_started": 1539810919,"time_finished": 1539810926,"rcpt_to": "tricia.mumford@transdev.com","tracking_id": "2f7a87e4-513e-4358-b1b6-bb8febdff35d","subject": "SV Alert Alert (#725159)"},"resp_msg": "5.4.1 [Theodrick.mccullom@transdev.com]: Recipient address rejected: Access denied [HE1EUR02FT033.eop-EUR02.prod.protection.outlook.com]","time_started": 1539815408,"time_finished": 1539815412,"tracking_id": "e9bb47c0-22d5-4781-ac2a-9bef56232255","subject": "Las Vegas Notification - Safety- Accident with no injuries (Auto Email u2013 Do (#733279)"},"resp_msg": "5.4.1 [francisco.sanchez@transdev.com]: Recipient address rejected: Access denied [HE1EUR02FT026.eop-EUR02.prod.protection.outlook.com]","time_started": 1539815465,"time_finished": 1539815469,"rcpt_to": "francisco.sanchez@transdev.com","tracking_id": "c5baf56c-89da-4388-a692-da2b84862f0a","subject": "Malfunctioning GPS,please reboot this these device(s). (#733299)"},"resp_msg": "5.4.1 [carl.parr@transdev.com]: Recipient address rejected: Access denied [HE1EUR02FT019.eop-EUR02.prod.protection.outlook.com]","time_started": 1539816062,"time_finished": 1539816067,"rcpt_to": "carl.parr@transdev.com","tracking_id": "e6299d04-5aac-43d3-8593-1a3c548e336f","subject": "SV Alert Alert (#733431)"},"resp_msg": "5.4.1 [Theodrick.mccullom@transdev.com]: Recipient address rejected: Access denied [HE1EUR02FT038.eop-EUR02.prod.protection.outlook.com]","time_started": 1539816315,"time_finished": 1539816318,"tracking_id": "ea9caff3-364e-4a32-8365-98a897a6bbc5","subject": "Las Vegas Notification - Safety- Accident with no injuries (Auto Email u2013 Do (#734371)"},"resp_msg": "5.4.1 [francisco.sanchez@transdev.com]: Recipient address rejected: Access denied [VE1EUR02FT035.eop-EUR02.prod.protection.outlook.com]","time_started": 1539820874,"time_finished": 1539820877,"tracking_id": "b81e47e5-5211-425a-a7be-5b75379bf3b1",please reboot this these device(s). (#735305)"},"resp_msg": "5.4.1 [francisco.sanchez@transdev.com]: Recipient address rejected: Access denied [VE1EUR02FT053.eop-EUR02.prod.protection.outlook.com]","time_started": 1539826279,"time_finished": 1539826283,"tracking_id": "c2b7a520-a994-49a6-b34b-96113f5960d5",please reboot this these device(s). (#735539)"},"resp_msg": "5.4.1 [Ramona.Trotter@transdev.com]: Recipient address rejected: Access denied [HE1EUR02FT023.eop-EUR02.prod.protection.outlook.com]","time_started": 1539829584,"time_finished": 1539829587,"rcpt_to": "ramona.trotter@transdev.com","tracking_id": "264645cd-0792-445b-9fd4-1cccd0746cfb","subject": "Driver Dispatch Log Entries (Auto Email u2013 Do Not Reply) (#736221)"}],"last_update_time": 1540421479.703088}";
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                DataSet dt = (DataSet)JsonConvert.DeserializeObject(str,(typeof(DataSet)));
            return new EmptyResult();
}

解决方法

你可以试试这个

string str = "{ 'context_name': { 'lower_bound': 'value','pper_bound': 'value','values': [ 'value1','valueN' ] } }";
    JavaScriptSerializer j = new JavaScriptSerializer();
    object a = j.Deserialize(str,typeof(object));

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读