Monday 15 September 2014

c# - Json.NET serialize collection partially -


How to sort partly archive based on certain conditions of the underlying objects? I have already seen the JsonConverter and contractor , but still do not understand it.

I am talking about the general case.

For example: IList , int number = & gt; Only numbers also want me to ignore certain things during the serialization.

I have created a sample in which I only sort numbers.

  Container Container = New Container (); Contrainer.full = Noteworthy. Category (1, 20) .oir (); JavaScriptSerializer serializer = new JavaScriptSerializer (); String str = serializer.Serialize (contrainer); Public Category Container [Script Ignore] Public Introd [No Serialize] [Full] {Received; Set; } Public Int32 [] Partial {// Want to get the serial that you want {Return it back complete. Where (i = & gt; (i% 2) == 0) .oir (); } Set {this.Full = value; }}}   

Results

  {"partial": [2,4,6,8,10,12, 14,16,18,20]}   

I hope this will be helpful.

No comments:

Post a Comment