This project has moved and is read-only. For the latest updates, please go here.

Guid Serializing?

Feb 9, 2010 at 10:39 PM

I am not able to get a guid to Serialize using JObject or JProperty.

How do you Serialize a Guid in a property?

var guid = Guid.NewGuid();

new JProperty("Guid",guid);//fails

new JProperty("Guid",JObject.FromObject(guid));//fails


Feb 10, 2010 at 3:10 AM


Feb 10, 2010 at 4:46 AM
I did get that to work. How ever, I have a situation where I am serializing an Id which is of type Object. It could be a Guid in some objects a long in others or even an anonymous type. The ToString() Method wont work there. I think I will have to change how Json.Net Handles Guids. Basically I will Change the new Property(string,object) to handle anything thrown at it and automatically create the JValue,JObject or JArray better.

-----Original Message-----
From: "JamesNK" <>
Sent: Tuesday, February 9, 2010 7:10pm
To: [email removed]
Subject: Re: Guid Serializing? [Json:83811]

From: JamesNK


Aug 10, 2011 at 6:20 PM

I'm having problems doing the opposite.  I'm trying to deserialize an object that has a GUID ID.  I get the following error: Error converting value \"EA6773FD-66FF-F005-7C26D2FBFEFB\" to type 'System.Guid'.  I have tried to take the '-' out but it still breaks.  Any ideas?

Aug 10, 2011 at 6:45 PM

evidentally, the guid generator was broken.  It's obviously not a valid GUID..