I was creating some nested objects and was wondering if there any shorter ways to get values from objects than this?
Code: Select all
#z::
carObj := [{"model" : ["BMW", "Tesla", "Audi", "Kia"]},{"color" : ["blue", "red", "yellow"]}]
; lets say you want to check if there is Kia in model and if you get modelToFind and objParam only in variable as below:
modelToFind := "Kia"
objParam := "model"
foundModel := 0
for index, value in carObj
{
for carParamName, data in value
{
if (carParamName = objParam)
{
for key, model in data
{
if (model = modelToFind)
{
foundModel := 1
}
}
}
}
}
MsgBox, % foundModel
return
Thank you for your time and answers in advance!