Json在C#类中反序列化。 [英] Json Deserialization in C# classes.

查看:89
本文介绍了Json在C#类中反序列化。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我坚持使用C#类的Json数组序列化。



我有json数组。值来自于以后在cammalcase中的API。当我在c#类中反序列化json数组时,那么value也在camelCase中去了deserilaizing。但序列化Json数组后我想在PascalCase中获得该值。



下面的一些代码。



Json数组。



{有效:真实,价值:15311,名称:Flipside Burger,有效期:false,错误:[{code:0004,msg:您使用外卡作为IP限制,这不安全。请提供您的IP地址给我们的支持!,输入:警告 }],token:552e4a11aa6b10b823adf2dcdf857ae9}





c #classes





Hi,

I stuck on the serialization of the Json Array in C# class.

I have json array. value is comming from API in cammalcase later. When I De-serialized that json array in c# class then value is also deserilaizing in camelCase. But i want that value in PascalCase after serializing the Json Array.

Some code below.

Json Array.

{"valid":"true","value":15311,"name":"Flipside Burger","expiry":false,"error":[{"code":"0004","msg":"your using a wild card as your IP limitation, this is not secure. Please provide your IP addresses to our support !","type":"warning"}],"token":"552e4a11aa6b10b823adf2dcdf857ae9"}


c# classes


[DataMember]
      
   
   
    
      [DataMember]
      public CookieContainer valid { get; set; }

     
 

      [DataMember]
      public string ConversionToID { get; set; }

   
      [DataMember]
      public string conversionFromID { get; set; }

      [DataMember]
      public string errorType { get; set; }


    
      [DataMember]
      public string mode { get; set; }

      [DataMember]
      public string message { get; set; }

      
      [DataMember]
      public string stepTo { get; set; }

     
      [DataMember]
      public string step_valueTo { get; set; }

But I need Data in 



      [DataMember]
      public string Mode { get; set; }

      [DataMember]
      public string Message { get; set; }

      
      [DataMember]
      public string StepTo { get; set; }

     
      [DataMember]
      public string Step_valueTo { get; set; }


any comment would be appreciable.

Thanks and regard.
Vikash

推荐答案

请浏览以下链接





http://stackoverflow.com / questions / 18627112 / how-can-i-convert-text-to-pascal-case [ ^ ]



https://msdn.microsoft.com/en-us/library/system.globalization .textinfo.totitlecase(v = vs.110).aspx [ ^ ]
please go through the following links


http://stackoverflow.com/questions/18627112/how-can-i-convert-text-to-pascal-case[^]

https://msdn.microsoft.com/en-us/library/system.globalization.textinfo.totitlecase(v=vs.110).aspx[^]


希望这有帮助



http:// www。 matskarlsson.se/blog/serialize-net-objects-as-camelcase-json [ ^ ]


这篇关于Json在C#类中反序列化。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆