%dw 2.0
import * from dw::Runtime
output application/json
var jsonDF = findDataFormatDescriptorByMime({'type': "*", subtype: "json", parameters: {}})
var unknownDF = findDataFormatDescriptorByMime({'type': "*", subtype: "*", parameters: {}})
fun simplify(df: DataFormatDescriptor | Null) = df match {
case d is DataFormatDescriptor -> { name: d.name, defaultMimeType: d.defaultMimeType }
case is Null -> { name: "unknown", defaultMimeType: "unknown" }
}
---
{
json: simplify(jsonDF),
unknown: simplify(unknownDF)
}
findDataFormatDescriptorByMime
findDataFormatDescriptorByMime(mime: dw::module::Mime::MimeType): DataFormatDescriptor | Null
Returns the DataFormatDescriptor based on the dw::module::Mime::MimeType specified or null if
there is no DataFormatDescriptor for the given MimeType.
Experimental: This function is an experimental feature that is subject to change or removal from future versions of DataWeave.
Introduced in DataWeave version 2.7.0.
Example
This example searches for a JSON DataFormatDescriptor and an unknown DataFormatDescriptor.



