Document property sort

37 views
Skip to first unread message

germanftorres

unread,
Sep 21, 2017, 3:53:08 AM9/21/17
to RavenDB - 2nd generation document database
Hi folks!

I'm trying out RavenDB.Client 4.0 RC and one of the things I've noticed is that the sort order of the properties of the serialized json is different than in previous versions.

Given this class:

public class MyEntity
{
        public string Username { get; set; }
        public string Password { get; set; }
        public string OrganizationId { get; set; }
        public string AgentDutyCode { get; set; } 
}

in 3.5 the document was serialized by the client with the properties in the same sort order as in the C# class definition.
{
            "Username": "user",
            "Password": "pass",
            "OrganizationId": "data",
            "AgentDutyCode": "data",
}


Now in Raven.Client 4.0 RC the json data gets posted to RavenDB with the properties sorted in alphabetical order.
{
            "AgentDutyCode": "data",
            "OrganizationId": "data",
            "Password": "pass",
            "Username": "user",
}

It's of course not a breaking change and it seems reasonable not to rely on json property ordering. However, given that a lot of work from a production system falls in the devops category I would guess that it makes sense to keep the same sort order as in the class definition. We tend to design entities with some ordering/grouping of properties in mind that is visually appealing for the person that has to open or edit a document in Studio and I think the client should respect that sorting decision that we make in the C# code.

I have tried to configure the Conventions through CustomizeJsonSerializerSettings and ContractResolver but with no luck.

Anybody knows how to revert to the previous behaviour?

Thanks!!!

Germán.



Oren Eini (Ayende Rahien)

unread,
Sep 21, 2017, 4:51:18 AM9/21/17
to ravendb
Hm...
a) You shouldn't rely on the order of the JSON.
b) This is likely because of the way we are serializing the data. We are now using blittable format internally, which is faster to generate in lexical order.

Hibernating Rhinos Ltd  

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

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

 


--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages