Dictionaries with DateTimeOffset as key fails to serialize

52 views
Skip to first unread message

Jimmy Rasmussen

unread,
Mar 26, 2015, 4:57:20 AM3/26/15
to rav...@googlegroups.com
Given an object of this type:

        class A
        {
            public IDictionary<DateTimeOffset, string> Items { get; set; }
        }

Serialization and deserialzation seems to be working fine with Json.Net, but when trying to store the object with ravenDB I get this error:

System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> Raven.Imports.Newtonsoft.Json.JsonWriterException : Token String in state ObjectStart would result in an invalid JSON object. Path 'Items'.


A solution could be to implement by own JsonConverter, but if this is a bug in the ravenDB adaptation of Json.Net it should get fixed.
Message has been deleted

Oren Eini (Ayende Rahien)

unread,
Mar 26, 2015, 8:53:32 AM3/26/15
to ravendb
Thanks, this will be fixed in the next build

Hibernating Rhinos Ltd  

Oren Eini l CEO Mobile: + 972-52-548-6969

Office: +972-4-622-7811 l Fax: +972-153-4-622-7811

 


On Thu, Mar 26, 2015 at 10:37 AM, Jimmy Rasmussen <jwei...@gmail.com> wrote:
Given objects of this type:

        class A
        {
            public IDictionary<DateTimeOffset, string> Items { get; set; }
        }


Serialization/Deserialization using Json.Net (JsonConvert.SerializeObject() and JsonConvert.DeserializeObject() ) seems to be working fine, but when trying to store the object in ravenDB I get this error:

System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> Raven.Imports.Newtonsoft.Json.JsonWriterException : Token String in state ObjectStart would result in an invalid JSON object. Path 'Items'.


My guess is that there is a bug in the ravenDB adaptation of Json.Net?

A solution could be to implement my own JsonConverter, but if it's a bug in ravenDB it should get fixed.

--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages