parseKeySlices

Split the json object into keys, store the slices from the input string into a newly created struct which contains all the keys from the fields parameter.

If a paremeter ends with _, the last _ will be removed in the string check, so that D reserved keywords can be used.

template parseKeySlices(fields...)
parseKeySlices
(
T
)
(
scope return T[] jsonObject
)
if (
is(immutable T == immutable char)
)

Members

Functions

parseKeySlices
auto parseKeySlices(T[] jsonObject)
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

string json = `{
	"hello": "ther\"e",
	"foo": {"ok":"cool"} ,
	"bar": [1, 2.0,3],
	"extra": {
		"f": [
			1 , {
				"a": "b",
				"c": false
			}, {
				"f": [1, {
					"a": "b",
					"c": false
				}],
				"a": 10000
			}
		],
		"a": 10000
	},
	"yes": true,
	"no": false,
	"opt": null
}`;
auto parts = json.parseKeySlices!("hello", "foo", "bar", "extra", "yes", "opt", "notinjson");
assert(!parts.notinjson.length);
assert(parts.hello is json[13 .. 22]);
assert(parts.foo is json[33 .. 46]);
assert(parts.bar is json[58 .. 68]);
assert(parts.extra is json[81 .. 246]);
assert(parts.yes is json[257 .. 261]);
assert(parts.opt is json[287 .. 291]);

Meta