User Tools

Site Tools


transformations:constructjson

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
transformations:constructjson [2021/04/14 10:19] andrewtransformations:constructjson [2021/04/24 23:46] craigt
Line 1: Line 1:
-===== Construct JSON =====+{{ transformations:ConstructJsonAction.png}} 
 +======CONSTRUCT JSON=====
 +Category: Transform / Advanced \\
  
 +\\ 
 +=====Description=====
 This action constructs a [[https://en.wikipedia.org/wiki/JSON|JSON]] object from a tabular dataset. It has two modes: This action constructs a [[https://en.wikipedia.org/wiki/JSON|JSON]] object from a tabular dataset. It has two modes:
   * 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 "Object per row" ====+\\  
 +=====Action settings===== 
 +==== Mode"Object per row" ====
 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:
      
 </code> </code>
- +\\  
-==== 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 modethe source dataset is converted into a new dataset in which values of each column are rolled up into a JSON array. For instancethe table from the example above would be converted into the following table:
  
 ^ ID ^ Name ^ ^ ID ^ Name ^
 | [1,2] | [Apple,Orange]  | | [1,2] | [Apple,Orange]  |
  
- +\\ \\  
-==== 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 ====+\\  
 +===== 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: 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:
  
Line 89: Line 96:
 } }
 </code> </code>
-Notice that "Location" is inserted as a JSON object, not as text. Also, field "Hiatus" is inserted as a JSON array, not as text.+Notice that "Location" is inserted as a JSON object, not as text. Also, the field "Hiatus" is inserted as a JSON array, not as text.
  
-==== See also ==== +\\  
-  * [[https://community.easymorph.com/t/example-constructing-json/1279/5|Example: Constructing JSON]]+===== See also =====
   * [[transformations:parsejson|Parse JSON]]   * [[transformations:parsejson|Parse JSON]]
-  * [[syntax:functions:isjson|isjson]] +  * [[syntax:functions:isjson|Functions:  IsJson()]] 
 +  * [[https://community.easymorph.com/t/example-constructing-json/1279/5|Community example: Constructing JSON]]
  
transformations/constructjson.txt · Last modified: 2022/10/02 20:16 by craigt

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki