asdf 0.0.7

A Simple Document Format

To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Dub version License Build Status

A Simple Document Format

ASDF is a cache oriented string based JSON representation. It allows to easily iterate over JSON arrays/objects multiple times without parsing them. ASDF does not parse numbers (they are represented as strings). ASDF values can be removed by setting deleted bit on.

For line separated JSON values see parseJsonByLine function. This function accepts a range of chunks instead of a range of lines.


ASDF is fast. It can be really helpful if you have gigabytes of JSON line separated values.


See ASDF Specification.

I/O Speed
  • Reading JSON line separated values and parsing them to ASDF - 300+ MB per second (SSD).
  • Writing ASDF range to JSON line separated values - 300+ MB per second (SSD).
ASDF Example
import std.algorithm;
import std.stdio;
import asdf;

void main()
	auto target = Asdf("red");
		// Use at least 4096 bytes for real wolrd apps
		// 32 is minimal value for internal buffer. Buffer can be realocated to get more memory.
		.filter!(object => object
			// opIndex accepts array of keys: {"key0": {"key1": { ... {"keyN-1": <value>}... }}}
			// iterates over an array
			// Comparison with ASDF is little bit faster
			//   then compression with a string.
		// Formatting uses internal buffer to reduce system delegate and system function calls

Single object per line: 4th and 5th lines are broken.

{"colors": ["red"]}
{"a":"b", "colors": [4, "red", "string"]}
	"comment" : "this is broken (multiline) object"}
{"colors": "green"}
{"colors": "red"]}}
JSON and ASDF Serialization Examples
Simple struct or object
struct S
	string a;
	long b;
	private int c; // private feilds are ignored
	package int d; // package feilds are ignored
	// all other fields in JSON are ignored
struct S
	// ignored
	int temp;
	// can be formatted to json
	int a;
	//can be parsed from json
	int b;
Key overriding
struct S
	// key is overrided to "aaa"
	int a;

	// overloads multiple keys for parsing
	@serializationKeysIn("b", "_b")
	// overloads key for generation
	int b;
User-Defined Serialization
struct DateTimeProxy
	DateTime datetime;
	alias datetime this;

	static DateTimeProxy deserialize(Asdf data)
		string val;
		deserializeScopedString(data, val);
		return DateTimeProxy(DateTime.fromISOString(val));

	void serialize(S)(ref S serializer)
Serialization Proxy
struct S
	DateTime time;
struct S
	string a;
	int b;

	double sum;

	void finalizeDeserialization(Asdf data)
		auto r = data["c", "d"];
		auto a = r["e"].get(0.0);
		auto b = r["g"].get(0.0);
		sum = a + b;
assert(`{"a":"bar","b":3,"c":{"d":{"e":6,"g":7}}}`.deserialize!S == S("bar", 3, 13));
  • Ilya Yaroshenko
0.7.15 2022-Jun-02
0.7.14 2022-Mar-24
0.7.13 2021-Nov-09
0.7.12 2021-Sep-23
0.7.11 2021-Jul-05
Show all 83 versions
Download Stats:
  • 102 downloads today

  • 149 downloads this week

  • 1021 downloads this month

  • 283574 downloads total

Short URL: