transformations:constructjson
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
transformations:constructjson [2021/04/14 10:19] – andrew | transformations:constructjson [2021/07/18 00:59] – craigt | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ===== Construct | + | {{ transformations: |
+ | ======CONSTRUCT | ||
+ | Category: Transform / Advanced \\ | ||
+ | \\ | ||
+ | =====Description===== | ||
This action constructs a [[https:// | This action constructs a [[https:// | ||
* Object per row, array from objects | * Object per row, array from objects | ||
* Array per column | * Array per column | ||
- | A constructed JSON object is effectively a regular text value that is stored in a datagrid cell in EasyMorph. | + | A constructed JSON object is effectively a regular text value that is stored in a datagrid cell in EasyMorph.\\ |
- | ==== Mode " | + | \\ |
+ | =====Action settings===== | ||
+ | ==== Mode: " | ||
In this mode, each row of the source dataset is used to construct a flat JSON object in which every column value corresponds to one object property. For instance, the dataset below: | In this mode, each row of the source dataset is used to construct a flat JSON object in which every column value corresponds to one object property. For instance, the dataset below: | ||
Line 47: | Line 53: | ||
| | ||
</ | </ | ||
- | + | \\ | |
- | ==== Mode "Array per column" | + | ==== Mode: "Array per column" |
- | In this mode the source dataset is converted into a new dataset in which values of each column are rolled up into a JSON array. For instance the table from the example above would be converted into the following table: | + | In this mode, the source dataset is converted into a new dataset in which values of each column are rolled up into a JSON array. For instance, the table from the example above would be converted into the following table: |
^ ID ^ Name ^ | ^ ID ^ Name ^ | ||
| [1,2] | [Apple, | | [1,2] | [Apple, | ||
- | + | \\ \\ | |
- | ==== Data type conversion ==== | + | ===== Data type conversion |
EasyMorph data types are converted to JSON types as follows: | EasyMorph data types are converted to JSON types as follows: | ||
Line 68: | Line 74: | ||
Note that the action fails if the source dataset contains an error value. | Note that the action fails if the source dataset contains an error value. | ||
- | ==== Nesting JSON objects ==== | + | \\ |
- | EasyMorph automatically detects if a text value is already a JSON object or a JSON array. In this case, the text value is inserted verbatim, i.e. **without** wrapping in double quotes. This feature allows creating complex hierarchical JSON objects that nest other JSON objects. For instance converting the table below: | + | ===== Nesting JSON objects |
+ | EasyMorph automatically detects if a text value is already a JSON object or a JSON array. In this case, the text value is inserted verbatim, i.e. **without** wrapping in double-quotes. This feature allows creating complex hierarchical JSON objects that nest other JSON objects. For instance, converting the table below: | ||
^ Track ^ Country | ^ Track ^ Country | ||
Line 89: | Line 96: | ||
} | } | ||
</ | </ | ||
- | Notice that " | + | Notice that " |
- | ==== See also ==== | + | \\ |
- | * [[https:// | + | =====Community examples===== |
- | * [[transformations:parsejson|Parse JSON]] | + | * [[https:// |
- | * [[syntax:functions:isjson|isjson]] | + | * [[https:// |
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | \\ | ||
+ | ===== See also ===== | ||
+ | * [[transformations: | ||
+ | * [[syntax: | ||
transformations/constructjson.txt · Last modified: 2022/10/02 20:16 by craigt