Suppose you have a flags enum in C#:

```
[Flags]
public enum FlagsEnum
{
    One = 0x1,
    Two = 0x2,
    Four = 0x4,
    ...
}

```

If you run this through standard JSON or XML serialization, `FlagsEnum.One` will be serialized as the string `One`, `FlagsEnum.Two` as `Two`, etc. If you wanted to change it to have the values serialized as the integers `1`, `2`, etc., a typical solution for enums in general is to use the `EnumMember` attribute or `XmlEnum` attribute.

The problem is that with a flags enum, you're expecting several numerical values to be used that aren't specifically declared. Googling around doesn't seem to turn up much a solution for that scenario. So how would you get something like this to be serialized to integer values that aren't simply powers of 2, showing things in the serialized form like `23`, `15`, etc.?

**EDIT**

Part of what I'm looking for is a way to specify this within the enum itself, without adding any extra values to the enum or properties to other types. There is a question in my mind, however, whether that is actually possible (basically speaking).

Also the main type of serializer that this is really coming up with at the moment is `DataContractSerializer`. However typical, standard JSON stuff would also be applicable to this question, and the goal is to avoid changing out the serializers themselves and using anything customer or off the beaten path. (Attributes and stuff would be good, if it can be done that way.)