nestedKeys

Get all the keys from your Json object. The levels will be separated by . or []

version(Have_vibe_d_data)
@trusted
string[]
nestedKeys
(
Json obj
)

Examples

Empty Json object keys

Json.emptyObject.nestedKeys.length.should.equal(0);

Get all keys from nested object

auto obj = Json.emptyObject;
obj["key1"] = 1;
obj["key2"] = 2;
obj["key3"] = Json.emptyObject;
obj["key3"]["item1"] = "3";
obj["key3"]["item2"] = Json.emptyObject;
obj["key3"]["item2"]["item4"] = Json.emptyObject;
obj["key3"]["item2"]["item5"] = Json.emptyObject;
obj["key3"]["item2"]["item5"]["item6"] = Json.emptyObject;

obj.nestedKeys.should.containOnly(["key1", "key2", "key3.item1", "key3.item2.item4", "key3.item2.item5.item6"]);

Get all keys from nested objects inside an array

auto obj = Json.emptyObject;
Json elm = Json.emptyObject;
elm["item5"] = Json.emptyObject;
elm["item5"]["item6"] = Json.emptyObject;

obj["key2"] = Json.emptyArray;
obj["key3"] = Json.emptyArray;
obj["key3"] ~= Json("3");
obj["key3"] ~= Json.emptyObject;
obj["key3"] ~= elm;
obj["key3"] ~= [ Json.emptyArray ];

obj.nestedKeys.should.containOnly(["key2", "key3[0]", "key3[1]", "key3[2].item5.item6", "key3[3]"]);

Meta