{{ transformations:ExtractJsonAction.png}}
======EXTRACT JSON PROPERTIES======
Category: Transform / Web \\
\\
=====Description=====
This action creates new columns with values from selected JSON [[https://en.wikipedia.org/wiki/JSON|JSON]] properties contained within a single-cell text string typically received from an API call.
\\
=====Action settings=====
^Setting ^Description ^
|Source JSON|Select the column that contains the JSON text.|
|New column names|Choose the mode for creating and naming columns from the selected JSON object. Options: //Property name//\\ or //Explicit//. See below for details.|
|JSON path|Select the specific JSON path(s) to extract into the defined columns. See below for details.|
|Position|Choose where the new columns will appear in the table. Options: //Rightmost//, //Leftmost//, or //After column// (and\\ select the column the new columns will appear after).|
|If JSON path not found|Choose how EasyMorph will respond to situations when the selected JSON path is not found in the dataset.\\ Options: //Fail// (and halt the workflow) or //Return error// (generate an error and continue the workflow).|
\\
==== New column names "Property name" settings ====
This mode will create a new column with the same name as the path selected in the "JSON path" setting.
\\
==== New column names "Explicit" settings ====
In this mode, individual columns are created, and manually named, based on the selected JSON paths.
\\ \\
=====Examples=====
**Source JSON:** Column name is "Response-Body" (all text contained within a single cell).\\
{"Employees":[{"name":"Doug", "id":7, "dept":"Accounting"},{"name":"Sue","id":2, "dept":"HR"},{"name":"Mark",
"id":5, "dept":"Maintenance"},{"name":"Tamara", "id":1, "dept":"Administration"}]}
\\
**Action parameters:**
> Source JSON is "Response-Body"
> New column names is "Property name"
> JSON path is "Employees"
\\
**Result:** (Contained within a single cell.)
[
{
"name": "Doug",
"id": 7,
"dept": "Accounting"
},
{
"name": "Sue",
"id": 2,
"dept": "HR"
},
{
"name": "Mark",
"id": 5,
"dept": "Maintenance"
},
{
"name": "Tamara",
"id": 1,
"dept": "Administration"
}
]
\\
===== See also =====
* [[transformations:modifyjson|Modify JSON]]
* [[transformations:parsejson|Parse JSON]]
* [[transformations:splitjsonarray|Split JSON array]]
* [[syntax:functions:isjson|Functions: IsJson()]]
* [[https://community.easymorph.com/t/example-constructing-json/1279/5|Community example: Constructing JSON]]