You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/2024.9/Reference/Concepts/fundamentals/blocks/block-properties/property-editors/expression-editor.md
Decomposition expressions are used to extract the properties of an [Output property][Output properties] and store them in [variables][Variables Concept].
565
+
566
+
{{% alert title="Note" %}}
567
+
This is currently only supported by output properties.
568
+
{{% /alert %}}
569
+
570
+
[Output properties][] can be decomposed using the decomposition syntax which includes the following syntaxes:
571
+
572
+
-[Property expression][Property expressions]
573
+
-[Index expression][Index expressions]
574
+
575
+
The decomposition syntax follows a very similar pattern to a `JSON` object:
576
+
577
+
- each `key` is the property path expression, where `$` is the root of the output value.
578
+
- each `value` is the variable name, prefixed with `($)`.
579
+
580
+
```json
581
+
{
582
+
"$.property.firstPath": ($)FirstVariable,
583
+
"$.property.secondPath": ($)SecondVariable
584
+
}
585
+
```
586
+
587
+
The examples below assumes that the output value contains the following JSON object:
588
+
589
+
```json
590
+
{
591
+
"company": {
592
+
"name": "Company Name",
593
+
"department": [
594
+
{
595
+
"name": "HR",
596
+
"employees": [
597
+
{
598
+
"name": "Joe Blogs",
599
+
"id": "101"
600
+
},
601
+
{
602
+
"name": "Jane Doe",
603
+
"id": "102"
604
+
}
605
+
]
606
+
},
607
+
{
608
+
"name": "Admin",
609
+
"employees": [
610
+
{
611
+
"name": "Jane Blogs",
612
+
"id": "103"
613
+
},
614
+
{
615
+
"name": "Joe Doe",
616
+
"id": "104"
617
+
}
618
+
]
619
+
}
620
+
]
621
+
}
622
+
}
623
+
```
624
+
625
+
### Decomposing an object property
626
+
627
+
To decompose this structure and store the departments, the syntax would be:
628
+
629
+
```json
630
+
{
631
+
"$.company.department": ($)ListOfDepartment
632
+
}
633
+
```
634
+
635
+
In this example, the variable `($)ListOfDepartment` will be set to the following value:
636
+
637
+
```json
638
+
[
639
+
{
640
+
"name": "HR",
641
+
"employees": [
642
+
{
643
+
"name": "Joe Blogs",
644
+
"id": "101"
645
+
},
646
+
{
647
+
"name": "Jane Doe",
648
+
"id": "102"
649
+
}
650
+
]
651
+
},
652
+
{
653
+
"name": "Admin",
654
+
"employees": [
655
+
{
656
+
"name": "Jane Blogs",
657
+
"id": "103"
658
+
},
659
+
{
660
+
"name": "Joe Doe",
661
+
"id": "104"
662
+
}
663
+
]
664
+
}
665
+
]
666
+
```
667
+
668
+
### Decomposing a list item
669
+
670
+
To decompose this structure and store the first `department`, the syntax would be:
671
+
672
+
```json
673
+
{
674
+
"$.company.department[0]": ($)FirstDepartment
675
+
}
676
+
```
677
+
678
+
In this example, the variable `($)FirstDepartment` will be set to the following value:
679
+
680
+
```json
681
+
{
682
+
"name": "HR",
683
+
"employees": [
684
+
{
685
+
"name": "Joe Blogs",
686
+
"id": "101"
687
+
},
688
+
{
689
+
"name": "Jane Doe",
690
+
"id": "102"
691
+
}
692
+
]
693
+
}
694
+
```
695
+
696
+
### Decomposing the last list item
697
+
698
+
To decompose this structure and store the last `employee` of the first `department`, the syntax would be:
Copy file name to clipboardExpand all lines: content/en/docs/2024.9/Reference/Concepts/fundamentals/blocks/block-properties/what-is-a-block-property.md
+9-66Lines changed: 9 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,11 +33,9 @@ Input properties can be configured using the following editors:
The icons used for Input properties are dark blue to distinguish them from [Output Properties][] or [InputOutput Properties][].
37
-
38
36
### Output Properties
39
37
40
-
Output properties are used to save values from a [block][]. These properties can be saved to a variable or decomposed to be saved into multiple variables during the block's execution.
38
+
Output properties are used to save values from a [block][]. These properties can be saved to a variable or [decomposed][Decomposing Output Properties] to be saved into multiple variables during the block's execution.
41
39
42
40
Values from Output properties can be [discarded][Discarding Outputs], this means they will not be saved to any variable.
43
41
@@ -49,72 +47,15 @@ Output properties can be configured using the following editors:
Output values can be decomposed to allow the saving of different parts of the value to different variables.
57
-
58
-
To decompose an output value, the output property will need to be set to an expression. As an example, an output value value contains a Json object, e.g:
59
-
60
-
```json
61
-
{
62
-
"company": {
63
-
"name": "Company Name",
64
-
"department": [
65
-
{
66
-
"name": "HR",
67
-
"employees": [
68
-
{
69
-
"name": "Joe Blogs",
70
-
"id": "101"
71
-
},
72
-
{
73
-
"name": "Jane Doe",
74
-
"id": "102"
75
-
}
76
-
]
77
-
}
78
-
]
79
-
}
80
-
}
81
-
```
82
-
83
-
To decompose this structure and store a part of the value to a variable, e.g. to get the employees for the first department, the syntax would be:
0 commit comments