---
schema_version: "1"
id: d20f80c6fe68b5577b5cbbb149436a13230af6f04d6c12c675520630f82f0672
title: objectFields
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/2.6/dw-types-functions-objectfields.md
canonical_url: https://docs.mulesoft.com/dataweave/2.6/dw-types-functions-objectfields
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 846505e23c676929eca0dbbc7f9a6778777d80d09662935814eb0e1ea573f7c6
description: MuleSoft Documentation Site
release: "2.6"
latest: false
---
---
product: DataWeave
version: 2.6
---

# objectFields

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## objectFields(t: Type): Array<Field>

Returns the array of fields from the given Object type. This function fails if the type is not an
Object type.

_Introduced in DataWeave version 2.3.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>t</code></p></td><td><p>The function type.</p></td></tr></tbody></table>

### Example

This example shows how `objectFields` behaves with different inputs.

#### Source

```DataWeave
import * from dw::core::Types
ns ns0 http://acme.com
type ADictionary = {_ : String}
type ASchema = {ns0#name @(ns0#foo: String): {}}
type AUser = {name @(foo?: String,l: Number)?: String, lastName*: Number}
---
{
    a: objectFields(ADictionary),
    b: objectFields(ASchema),
    c: objectFields(Object),
    d: objectFields(AUser)
}
```

#### Output

```Json
{
  "a": [
    {
      "key": {
        "name": {
          "localName": "_",
          "namespace": null
        },
        "attributes": [

        ]
      },
      "required": true,
      "repeated": false,
      "value": "String"
    }
  ],
  "b": [
    {
      "key": {
        "name": {
          "localName": "name",
          "namespace": "http://acme.com"
        },
        "attributes": [
          {
            "name": {
              "localName": "foo",
              "namespace": "http://acme.com"
            },
            "value": "String",
            "required": true
          }
        ]
      },
      "required": true,
      "repeated": false,
      "value": "Object"
    }
  ],
  "c": [

  ],
  "d": [
    {
      "key": {
        "name": {
          "localName": "name",
          "namespace": null
        },
        "attributes": [
          {
            "name": {
              "localName": "foo",
              "namespace": null
            },
            "value": "String",
            "required": false
          },
          {
            "name": {
              "localName": "l",
              "namespace": null
            },
            "value": "Number",
            "required": true
          }
        ]
      },
      "required": false,
      "repeated": false,
      "value": "String"
    },
    {
      "key": {
        "name": {
          "localName": "lastName",
          "namespace": null
        },
        "attributes": [

        ]
      },
      "required": true,
      "repeated": true,
      "value": "Number"
    }
  ]
}
```
