vibe.d beta banner
get vibe.d
0.8.1

Asynchronous I/O that doesn’t get in your way, written in D

Function name

Attribute for overriding the field name during (de-)serialization.

NameAttribute!Policy name(alias Policy) (
  string name
);

Note that without the @name attribute there is a shorter alternative for using names that collide with a D keyword. A single trailing underscore will automatically be stripped when determining a field name.

Example

struct CustomPolicy {}

struct Test {
	// serialized as "screen-size":
	@name("screen-size") int screenSize;

	// serialized as "print-size" by default,
	// but as "PRINTSIZE" if CustomPolicy is used for serialization.
	@name("print-size")
	@name!CustomPolicy("PRINTSIZE")
	int printSize;

	// serialized as "version"
	int version_;
}
Authors

Sönke Ludwig

Copyright

© 2013-2016 rejectedsoftware e.K.

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.