vibe.d beta banner
get vibe.d
0.10.1

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

Function serializeToPrettyJson

Serializes the given value to a pretty printed JSON string.

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

string serializeToPrettyJson(T) (
  auto ref 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.