How to check if JSONValue of type object has a key?

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Oct 6 13:43:58 PDT 2015


On Tue, Oct 06, 2015 at 08:28:46PM +0000, Borislav Kosharov via Digitalmars-d-learn wrote:
> JSONValue root = parseJSON(text);
> if(root["key"].isNull == false) {

try

if("key" in root) {
	// it is there
} else {
	// it is not there
}


you can also do

if("key" !in root) {}



More information about the Digitalmars-d-learn mailing list