Search notes:

Overpass API function u

The purpose of u(…) is to return a single unique value for a set (typically with exactly one member/element).
If the set has no element, an empty string is returned, if the set has mulitple elements with different values, u(…) returns < multiple values found >.

Use in foreach

The following query finds elements whose ele value end in m or m. and outputs then in JSON.
[out:json];
nwr[ele~'\s*m\\.?$'];

foreach {
   make x
    ::id   = u(id()),
//  ::type = u(type()),    // why oh why does that not work?
//    id   = u(id()),      // ::id works, therefore commented!
      type = u(type()),
      ele  = u(t['ele']);
 
   out;
}

See also

Compare with the set function which returns a text where the set's members's values are separated by a semicolon.
Overpass API: functions

Index