Data Structures JSON: Return 'false value' when we point to a json field which does not exist

+1 vote
asked Apr 16, 2020 in Wanted features by The-Lu (12,840 points)

First: Thanks for your json developpment.

Could you add this functionality :

  • Return 'false value' (for testing on '!if' function) [or 'undef'] when we point to a json field which does not exist (for a element on the json data) ?

For example : What's happen when a data is missing on a json Data Structures (example, with a 'color' field missing for the 'eve' employee)

Here is an example:

!$foo = { "company": "Skynet", "employees" : [
  {"name" : "alice", "salary": 100, "color" : "pink"},
  {"name" : "bob", "salary": 50, "color" : ""},
  {"name" : "carol", "salary": 50, "color": false},
  {"name" : "dave", "salary": 50, "color" : null}
  ',{"name" : "eve", "salary": 50}

!foreach $emp in $foo.employees
  !if $emp.color
    #$emp.color:The salary of $ is $emp.salary (color: $emp.color);
    :The salary of $ is $emp.salary (color: no color);


In order to test, please to uncomment the line, : ',{"name" : "eve", "salary": 50}

Thanks for your actions,

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

[Antispam2 Feature: please please wait 1 or 2 minutes (this message will disappear) before pressing the button otherwise it will fail](--------)
To avoid this verification in future, please log in or register.