简体   繁体   中英

Explanation of $ in Mule MEL

I cannot find any documentation around the use of $ in MEL other than a couple of lines here

You can refer to any Java class by its fully qualified name or if it is one of the classes in the automatically-imported Java classes, by its unqualified name. References use the same dot notation as in Java, except that you must use $ rather than a dot to refer to a nested class.

I can find a couple of examples here

JSON processing MEL has no direct support for JSON. The json-to-object-transformer can turn a JSON payload into a hierarchy of simple data structures that are easily parsed with MEL. For example, the following uses a filtered projection to build the equivalent of the

$..[?
(@.title=='Moby Dick')].price JSON path expression:
<json:json-to-object-transformer returnClass="java.lang.Object" />
<expression-transformer
 expression="#[($.price in message.payload if $.title == 'Moby Dick')[0]]" />

I want to understand in which cases does the $ get used...

$ comes from MVEL, the language underlying MEL.

$ serves as the placeholder for the element being filtered. It is actually a regular variable that exists inside the context of the projection. You can also use it to return the current element in the projection to the representative list.

Reference: http://mvel.codehaus.org/MVEL+2.0+Projections+and+Folds#MVEL2.0ProjectionsandFolds-Filters

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM