parse

Parses an associative array from a string given the left bracket (default '['), right bracket (default ']'), key-value separator (default ':'), and element seprator (by default ',').

Parameters

s Source

the string to parse

lbracket dchar

the character that starts the associative array

rbracket dchar

the character that ends the associative array

keyval dchar

the character that associates the key with the value

comma dchar

the character that separates the elements of the associative array

Return Value

Type: Target

An associative array of type Target

Examples

auto s1 = "[1:10, 2:20, 3:30]";
auto aa1 = parse!(int[int])(s1);
assert(aa1 == [1:10, 2:20, 3:30]);

auto s2 = `["aaa":10, "bbb":20, "ccc":30]`;
auto aa2 = parse!(int[string])(s2);
assert(aa2 == ["aaa":10, "bbb":20, "ccc":30]);

auto s3 = `["aaa":[1], "bbb":[2,3], "ccc":[4,5,6]]`;
auto aa3 = parse!(int[][string])(s3);
assert(aa3 == ["aaa":[1], "bbb":[2,3], "ccc":[4,5,6]]);

Meta

Suggestion Box / Bug Report