vibe.d beta banner
get vibe.d

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.


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.
	int printSize;

	// serialized as "version"
	int version_;

Sönke Ludwig


© 2013-2016 rejectedsoftware e.K.


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