vibe.d beta banner
get vibe.d
0.7.30

Function serializeToPrettyJson

Serializes the given value to a pretty printed JSON string.

Prototypes

void serializeToPrettyJson(R, T)(
  R destination,
  T value
)
if (isOutputRange!(R, char) || isOutputRange!(R, ubyte));

string serializeToPrettyJson(T)(
  T value
);

See also

serializeToJson, vibe.data.serialization

Example

struct Foo {
	int number;
	string str;
}

Foo f;
f.number = 12;
f.str = "hello";

string json = serializeToPrettyJson(f);
assert(json ==
`{
"number": 12,
"str": "hello"
}`);
Authors

Sönke Ludwig

Copyright

© 2012-2015 RejectedSoftware e.K.

License

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