Best practice property names (JsonProperty)


#1

Hello

What is the best practice for property names of the json object. I have a list of this object nested in a other object.
I check the document size on the server with Example1 every document is smaller.
On 1000 items i can reduce the size about 14% with only one property.

Example1:

public class File
{
[JsonProperty(“n”)]
public string Name { get; set; }
}

Example2:

public class File
{
[JsonProperty(“name”)]
public string Name { get; set; }
}


#2

Hi,

This really depends on who’s going to access this data and how. If you have complete control on the data and the clients then you can probably use short name like this. But then if someone else has to use this data and end up with letters instead of fieldname, they are going to have a hard time dealing with this model.

For this reason I would personally go against using one letter field name. This is true for the data but also for the views you might have created. Your map function might become a bit cryptic :slight_smile:

Having said that, if you have strong size restriction, you probably don’t have the choice anyway.