JMSSerializerBundle. no control over third party meta data

I bet xxx\xxx\Entity\User: refers to your own namespace and class. If it is, it is the wrong way to do. The rules must be applied to the class where the properties live. Given the property you exposed in your configuration, I guess you’re using FOSUserBundle. Therefore, you must apply your rules on FOS\UserBundle\Model\User. Then you … Read more

Biggest differences of Thrift vs Protocol Buffers? [closed]

They both offer many of the same features; however, there are some differences: Thrift supports ‘exceptions’ Protocol Buffers have much better documentation/examples Thrift has a builtin Set type Protocol Buffers allow “extensions” – you can extend an external proto to add extra fields, while still allowing external code to operate on the values. There is … Read more

How do I serialize an enum without including the name of the enum variant?

You can use the untagged attribute which will produce the desired output. You won’t need to implement Serialize yourself with this: #[derive(Debug, Serialize)] #[serde(untagged)] enum TValue<‘a> { String(&’a str), Int(&’a i32), } If you wanted to implement Serialize yourself, I believe you want to skip your variant so you should not use serialize_newtype_variant() as it … Read more

Conditional member serialization based on query parameter?

One possibility would be to introduce a custom attribute JsonConditionalIncludeAttribute that can be applied to properties and fields: [System.AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true, Inherited = true)] public class JsonConditionalIncludeAttribute : System.Attribute { public JsonConditionalIncludeAttribute(string filterName) { this.FilterName = filterName; } public string FilterName { get; private set; } } Next, subclass DefaultContractResolver, override CreateProperty, … Read more

custom serializer for just one property in Json.NET

You can add a custom serializer to a single attribute like this: public class Comment { public string Author { get; set; } [JsonConverter(typeof(NiceDateConverter))] public DateTime Date { get; set; } public string Text { get; set; } } public class NiceDateConverter : JsonConverter { public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { … Read more