Contact Us 1-800-596-4880

objectFields

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

Name Description

t

The function type.

Example

This example shows how objectFields behaves with different inputs.

Source

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

{
  "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"
    }
  ]
}