[Mono-list] DataContractJsonSerializer Gives Different Results Depending OS

fletcham fletcham at gmail.com
Tue Mar 22 21:06:03 EDT 2011


Will do, thank you!

-Adam

On Tue, Mar 22, 2011 at 8:23 PM, Atsushi Eno-2 [via Mono] <
ml-node+3398143-2071753897-222287 at n4.nabble.com> wrote:

> Please rather file a bug on bugzilla so that it don't flow away thanks.
>
> Atsushi Eno
>
> (2011/03/21 1:33), fletcham wrote:
>
> > I have written a small client - server application which passes JSON
> messages
> > back and forth.  The computer with the server application is running
> Windows
> > 7 and the client application is on a Mac as well as on the iPhone using
> > MonoTouch.  When I serialize an object utilizing the
> > DataContractJsonSerializer it gives me two different JSON responses
> > depending on the OS I am using.
> >
> > On Windows 7 using mono/.net 3.5 it gives me this result:
> >
> > [{"Suit":0},{"Suit":1},{"Suit":2}]
> >
> > On OSX 10.6.5 using mono/.net 3.5 it gives me this result:
> >
> >
> [{"__type":"Card:#JsonTest","Suit":0},{"__type":"Card:#JsonTest","Suit":1},{"__type":"Card:#JsonTest","Suit":2}]
>
> >
> > Has anyone run into a similar problem or is this to be expected?
> >
> > I have included a simple console application demonstrating the results
> > listed above.  For the console application to run you need to include two
>
> > reference: System.Runtime.Serialization and System.ServiceModel.Web.  If
> > anyone has any input on why this is and how to remedy it, it would be
> > greatly appreciated!
> >
> > Thank you,
> > Adam
> >
> >
> > using System;
> > using System.Collections.Generic;
> > using System.Runtime.Serialization.Json;
> > using System.IO;
> > using System.Text;
> >
> > namespace JsonTest
> > {
> > class MainClass
> > {
> > public static void Main(string[] args)
> > {
> > Hand hand = new Hand();
> > hand.Add(new Card { Suit = 0 });
> > hand.Add(new Card { Suit = 1 });
> > hand.Add(new Card { Suit = 2 });
> >
> > string json;
> >
> > DataContractJsonSerializer ser = new
> > DataContractJsonSerializer(hand.GetType());
> > using (MemoryStream ms = new MemoryStream())
> > {
> > ser.WriteObject(ms, hand);
> > json = Encoding.Default.GetString(ms.ToArray());
> > }
> >
> > Console.WriteLine(json);
> > }
> > }
> >
> > public class Card
> > {
> > public int Suit { get; set; }
> > }
> >
> > public class Hand : List
> > {
> >
> > }
> > }
> >
> >
> > --
> > View this message in context:
> http://mono.1490590.n4.nabble.com/DataContractJsonSerializer-Gives-Different-Results-Depending-OS-tp3391376p3391376.html<http://mono.1490590.n4.nabble.com/DataContractJsonSerializer-Gives-Different-Results-Depending-OS-tp3391376p3391376.html?by-user=t>
> > Sent from the Mono - General mailing list archive at Nabble.com.
> > _______________________________________________
> > Mono-list maillist  -  [hidden email]<http://user/SendEmail.jtp?type=node&node=3398143&i=0&by-user=t>
> > http://lists.ximian.com/mailman/listinfo/mono-list
> >
> >
> >
>
> _______________________________________________
> Mono-list maillist  -  [hidden email]<http://user/SendEmail.jtp?type=node&node=3398143&i=1&by-user=t>
> http://lists.ximian.com/mailman/listinfo/mono-list
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://mono.1490590.n4.nabble.com/DataContractJsonSerializer-Gives-Different-Results-Depending-OS-tp3391376p3398143.html
>  To unsubscribe from DataContractJsonSerializer Gives Different Results
> Depending OS, click here<http://mono.1490590.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3391376&code=ZmxldGNoYW1AZ21haWwuY29tfDMzOTEzNzZ8LTEzNjcyNzQxMzk=>.
>
>


--
View this message in context: http://mono.1490590.n4.nabble.com/DataContractJsonSerializer-Gives-Different-Results-Depending-OS-tp3391376p3398188.html
Sent from the Mono - General mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20110322/45a647e8/attachment.html 


More information about the Mono-list mailing list