---
schema_version: "1"
id: 7926375616641b4ac3a7ab87c23c4eb00c5a511c521bbd52a9aa6e2ddeb9eff6
title: fromString
collection: mulesoft
version: current
locale: ja-jp
portal_url: https://docs.salesforce.com/mulesoft/current/ja-jp/dataweave/2.8/dw-mime-functions-fromstring.md
canonical_url: https://docs.mulesoft.com/jp/dataweave/2.8/dw-mime-functions-fromstring
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 308872102521ac842664c52d585974e6fbc62ae962cb174dd2a82b7ede6e431d
description: MuleSoft Documentation Site
release: "2.8"
latest: false
---
# fromString

## [](#fromstring1)fromString(mimeType: String): Result<MimeType, MimeTypeError>

MIME タイプの文字列値表現を ​`MimeType`​ に変換します。

_DataWeave バージョン 2.7.0 で導入されました。_

### [](#パラメーター)パラメーター

<table class="tableblock frame-all grid-all stretch">
<colgroup>
<col style="width: 20%;">
<col style="width: 20%;">
<col style="width: 60%;">
</colgroup>
<thead>
<tr>
<th class="tableblock halign-left valign-top">名前</th>
<th class="tableblock halign-left valign-top">型</th>
<th class="tableblock halign-left valign-top">説明</th>
</tr>
</thead>
<tbody>
<tr>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>mimeType</code></p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock">String (文字列)</p></td>
<td class="tableblock halign-left valign-top"><p class="tableblock"><code>MimeType</code>​ に変換する MIME タイプの文字列値。</p></td>
</tr>
</tbody>
</table>

### [](#例)例

次の例では、​`parameters`​ が含まれない MIME タイプの文字列値を ​`MimeType`​ 値に変換します。

#### [](#ソース)ソース

```DataWeave
%dw 2.0
import * from dw::module::Mime
output application/json
---
fromString("application/json")
```

#### [](#出力)出力

```Json
{
  "success": true,
  "result": {
      "type": "application",
      "subtype": "json",
      "parameters": {}
  }
}
```

### [](#例-2)例

次の例では、​`parameters`​ が含まれる MIME タイプの文字列値を ​`MimeType`​ 値に変換します。

#### [](#ソース-2)ソース

```DataWeave
%dw 2.0
import * from dw::module::Mime
output application/json
---
fromString("multipart/form-data; boundary=the-boundary")
```

#### [](#出力-2)出力

```Json
{
  "success": true,
  "result": {
      "type": "multipart",
      "subtype": "form-data",
      "parameters": {
          "boundary": "the-boundary"
      }
  }
}
```

### [](#例-3)例

次の例では、無効な MIME タイプの文字列値を変換します。

#### [](#ソース-3)ソース

```DataWeave
%dw 2.0
import * from dw::module::Mime
output application/json
---
fromString("Invalid MIME type")
```

#### [](#出力-3)出力

```Json
{
  "success": false,
  "error": {
      "message": "Unable to find a sub type in `Invalid MIME type`."
  }
}
```