Page 1 of 1

variable on json file

Posted: Mon Mar 29, 2021 7:11 pm
by Silvio.Falconi
I have a json file with some variables
{
"antonio": "888",
"silvio": "789",
"paul": "456",
"mary": "123"
}

If not found a variable there is not on json

::oConfig := hb_jsonDecode(MemoRead("config.json"))
lstatus := ::oConfig["status"]

the procedure make error because it not found the variable status

how do I tell the procedure that if status is a valid variable or not, that is, if it does not find it, it must set the .f value to lstatus. otherwise .t.

or existe a function type jsonlistkeys where I can see if exit that variable ?

Re: variable on json file

Posted: Mon Mar 29, 2021 7:28 pm
by nageswaragunupudi

Code: Select all | Expand


if HB_HHasKey( ::oConfig, "status" )
   ? ::oConfig[ "status" ]
else
   ? <your message>
endif
 

Re: variable on json file

Posted: Mon Mar 29, 2021 7:41 pm
by Silvio.Falconi
thanks Rao