Converting dynamic type to dictionary C#

前端 未结 7 1269
执念已碎
执念已碎 2021-01-01 11:22

I have a dynamic object that looks like this,

 {
    \"2\" : \"foo\",
    \"5\" : \"bar\",
    \"8\" : \"foobar\"
 }

How can I convert this

7条回答
  •  盖世英雄少女心
    2021-01-01 11:57

    Another way is using System.Web.Helpers.Json included in .NET 4.5.

    Json.Encode(object) and Json.Decode. Like:

    Json.Decode>(value);
    

    MSDN: https://msdn.microsoft.com/en-us/library/gg547931(v=vs.111).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1

    Regards, MarianoC.

提交回复
热议问题