Skip to main content

PARSEOBJECT Function

Evaluates a String input against the Object datatype. If the input matches, the function outputs an Object value. Input can be a literal, a column of values, or a function returning String values.

After you have converted your strings to objects, if a sufficient percentage of input strings from a column are successfully converted to the other data type, the column may be retyped.

ヒント

If the column is not automatically retyped as a result of this function, you can manually set the type to Object in a subsequent recipe step.

Wrangle vs. SQL: This function is part of Wrangle, a proprietary data transformation language. Wrangle is not SQL. For more information, see Wrangle Language.

Basic Usage

parseobject(strInput)

Output: Returns the Object data type value for strInput String values.

Syntax and Arguments

parseobject(str_input)

Argument

Required?

Data Type

Description

str_input

Y

String

Literal, name of a column, or a function returning String values to match

For more information on syntax standards, see Language Documentation Syntax Notes.

str_input

Literal, column name, or function returning String values that are to be evaluated for conversion to Object values.

  • Missing values for this function in the source data result in null values in the output.

  • Multiple columns and wildcards are not supported.

Usage Notes:

Required?

Data Type

Example Value

Yes

String

{"1","2","3"}

Examples

ヒント

For additional examples, see Common Tasks.

Example - parsing strings as objects

The following table shows a series of requests for inventory on three separate products. These are rolling requests, so inventory levels in the subsequent request are decreased based on the previous request.

date

reqProdId

reqValue

prodA

prodB

prodC

5/10/21

prodA

10

90

100

100

5/10/21

prodC

20

90

100

80

5/10/21

prodA

15

75

100

80

5/11/21

prodB

25

75

75

80

5/11/21

prodA

5

70

75

80

5/11/21

prodC

30

70

75

50

5/12/21

prodB

10

70

65

50

You must create a column containing the request information and the inventory level information for the requested product after the request has been fulfilled.

Transformation:

The five data columns must be nested into an Object. The generated column is called inventoryLevels.

Transformation Name

Nest columns into Objects

Parameter: Columns

reqProdId,reqValue,prodA,prodB,prodC

Parameter: Nest columns to

Object

Parameter: New column name

inventoryLevels

You can then build the inventory response column (inventoryResponse) using the FILTEROBJECT function:

Transformation Name

New formula

Parameter: Formula type

Single row formula

Parameter: Formula

filterobject(parseobject(inventoryRequest), ['reqProdId','reqValue',reqProdId])

Parameter: New column name

inventoryResponse

Results:

The inventoryResponse column contains the request information and the response information after the request has been fulfilled.

date

reqProdId

reqValue

prodA

prodB

prodC

inventoryLevels

inventoryResponse

5/10/21

prodA

10

90

100

100

{"reqProdId":"prodA","reqValue":"10","prodA":"90","prodB":"100","prodC":"100"}

{"reqProdId":"prodA","reqValue":"10","prodA":"90"}

5/10/21

prodC

20

90

100

80

{"reqProdId":"prodC","reqValue":"20","prodA":"90","prodB":"100","prodC":"80"}

{"reqProdId":"prodC","reqValue":"20","prodC":"80"}

5/10/21

prodA

15

75

100

80

{"reqProdId":"prodA","reqValue":"15","prodA":"75","prodB":"100","prodC":"80"}

{"reqProdId":"prodA","reqValue":"15","prodA":"75"}

5/11/21

prodB

25

75

75

80

{"reqProdId":"prodB","reqValue":"25","prodA":"75","prodB":"75","prodC":"80"}

{"reqProdId":"prodB","reqValue":"25","prodB":"75"}

5/11/21

prodA

5

70

75

80

{"reqProdId":"prodA","reqValue":"5","prodA":"70","prodB":"75","prodC":"80"}

{"reqProdId":"prodA","reqValue":"5","prodA":"70"}

5/11/21

prodC

30

70

75

50

{"reqProdId":"prodC","reqValue":"30","prodA":"70","prodB":"75","prodC":"50"}

{"reqProdId":"prodC","reqValue":"30","prodC":"50"}

5/12/21

prodB

10

70

65

50

{"reqProdId":"prodB","reqValue":"10","prodA":"70","prodB":"65","prodC":"50"}

{"reqProdId":"prodB","reqValue":"10","prodB":"65"}