c# - JSON Serialization with class inheriting from Dictionary<T,V> -


I have a class that is currently the successor to the dictionary and after that some first-class member attributes are broadly On:

  Public Square Fu: Dictionary & lt; String, string & gt; {Public string bar {get; Set; } Public string playback {received; Set; }}  

On serializing an example of this object for JSON, it appears that the serializer uses only the key / value coupling that I have stored in the dictionary even here That if I apply the datamember attributes to the new 1 square properties, then the JSON serializer does not know what to do with them and instead of just ignoring them.

I am assuming that there is something fundamental in my priority that I am 'missing, but on Code.net's samples and docs, on NSN's JSON serializer, I only get trivial examples of what I I am doing that, which does not quite match. All our other classes that are received from some other base classes do not show this problem, this is what comes out especially with the generic dictionary that fits us.

[edit] A dictionary in Fu as a first class property, is it anyway to do the job anyway? I am assuming that the dangers are that the serializer does not know what the word "name" is to separate it from other members?

Perhaps a structure-based solution would be better in this example:

  Using the system; Using System.Collections.Generic; Using System.Runtime.Serialization.Json; Using System.IO; Using System.Text; Class Program {Static Wide Men () {Fu Fu = New Fu {Bar = "Bar", Falcon = "Falcon"}; Foo.Items.Add ("First", "First"); Data Contraception Serializer Serializer = New Data Contracts Surgery (Typef (Foo)); (Memorystream ms = new memorystream ()) using {serializer.WriteObject (ms, foo); Console.WriteLine (Encoding.Default.GetString (ms.ToArray ()); }}} Public square fu {public dictionary & lt; String, string & gt; Item {get; Set; } Public string bar {get; Set; } Public string playback {received; Set; } Public Foo () {this.Items = New Dictionary & lt; String, string & gt; (); }}  

This output produces:

{"bar": "bar", "falcon": "falcon", "Items": Will this solve your problem as a workaround?


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -