{{ transformations:ExtractJsonAction.png}}
======EXTRACT JSON PROPERTIES======
Category: Transform / Web \\

\\ 
=====Description=====
This action creates new columns with values from selected [[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.

\\
=====Remarks=====
All output text is contained within a single cell.  Text in this cell will not be fully visible in the dataset table cell due to linebreaks.

\\ 
=====Examples=====
====Example #1====
>Source JSON:**  Column name is "Response-Body" (all text contained within a single cell).\\
===Before (source table)===
<code>
{"Employees":[{"name":"Doug", "id":7, "dept":"Accounting"},{"name":"Sue","id":2, "dept":"HR"},{"name":"Mark",
 "id":5, "dept":"Maintenance"}]}
</code>

===After (result table)===
>All contained within a single cell.
<code>
[
  {
    "name": "Doug",
    "id": 7,
    "dept": "Accounting"
  },
  {
    "name": "Sue",
    "id": 2,
    "dept": "HR"
  },
  {
    "name": "Mark",
    "id": 5,
    "dept": "Maintenance"
  }
]
</code>

===Action parameters===
> Source JSON: Response-Body
> New column names: Property name
> JSON path: Employees
> Position: Rightmost
> If JSON path not found: Fail

\\
=====Community examples=====
  * [[https://community.easymorph.com/t/example-constructing-json/1279/5|Community example: Constructing JSON]]

\\ 
===== See also =====
  * [[transformations:modifyjson|Modify JSON]]
  * [[transformations:parsejson|Parse JSON]]
  * [[transformations:splitjsonarray|Split JSON array]]
  * [[syntax:functions:isjson|Functions:  IsJson()]]
