Does protobuf-net have built-in compression for serialization?

No it does not; there is no “compression” as such specified in the protobuf spec; however, it does (by default) use “varint encoding” – a variable-length encoding for integer data that means small values use less space; so 0-127 take 1 byte plus the header. Note that varint by itself goes pretty loopy for negative … Read more

What is the purpose of using @field:SerializedName annotation instead of @SerializedName?

TL;DR: The field: part is known as a “use-site target”, and makes it clear that the annotation is applied to the backing field of the Kotlin property. It is not strictly necessary in this case, though it can make the code more readable. Explanation To simplify, let’s say you have: data class Repo( @field:SerializedName(“name”) var … Read more

ShouldSerialize*() vs *Specified Conditional Serialization Pattern

The intent of the {propertyName}Specified pattern is documented in XML Schema Binding Support: MinOccurs Attribute Binding Support. It was added to support an XSD schema element in which: The <element> element is involved. minOccurs is zero. The maxOccurs attribute dictates a single instance. The data type converts to a value type. In this case, xsd.exe … Read more

JSON.stringify escaping without need

You are stringifying a string, not an object: var str=”{“2003”:{“1”:{“2”:[“test”],”3″:[“test2″]}}}”; var obj = {“2003”:{“1”:{“2”:[“test”],”3″:[“test2″]}}}; console.log( JSON.stringify(str) ); // {\”2003\”:{\”1\”:{\”2\”:[\”test\”],\”3\”:[\”test2\”]}}} console.log( JSON.stringify(obj) ); // {“2003”:{“1”:{“2”:[“test”],”3″:[“test2”]}}}

SignalR : use camel case

Roll your own Conttract resolver like public class SignalRContractResolver : IContractResolver { private readonly Assembly assembly; private readonly IContractResolver camelCaseContractResolver; private readonly IContractResolver defaultContractSerializer; public SignalRContractResolver() { defaultContractSerializer = new DefaultContractResolver(); camelCaseContractResolver = new CamelCasePropertyNamesContractResolver(); assembly = typeof(Connection).Assembly; } public JsonContract ResolveContract(Type type) { if (type.Assembly.Equals(assembly)) { return defaultContractSerializer.ResolveContract(type); } return camelCaseContractResolver.ResolveContract(type); } } Register … Read more