%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)
}
DataWeave
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.
Parameters
Name | Type | Description |
---|---|---|
|
|
The MIME type value to search. |
Example
This example searches for a JSON DataFormatDescriptor
and an unknown DataFormatDescriptor
.
Source
Output
{
"json": {
"name": "json",
"defaultMimeType": "application/json"
},
"unknown": {
"name": "unknown",
"defaultMimeType": "unknown"
}
}
Json