Tariq Husain
Tariq Husain

Reputation: 566

check is json key exists or not in freemarker

im getting json data from one api my respons is below and im putting it in notes variable. {"fitbit_reg_set":"fitbit_create_uname","fitbit_profile_set":"fitbit_create_uname"}

<#assign notes =  notes?eval>

<#if notes.fitbit_profile_set>

it works if fitbit_profile_set is present in json . but if that is not present my script stop working .How i can check if that is exists can anyone tell me ?

Upvotes: 1

Views: 2268

Answers (1)

Mostafa Darwish
Mostafa Darwish

Reputation: 91

You should add "??" so it will check if fitbit_profile_set exists and not null

<#if notes.fitbit_profile_set??>

Upvotes: 3

Related Questions