JSON operator
The JSON operator is property that creates JSON from specified properties or, in common case, from form.
Syntax
JSON FROM [columnId1 =] propertyExpr1, ..., [columnIdN = ] propertyExprN
[WHERE whereExpr] [ORDER orderExpr1 [DESC], ..., orderExprL [DESC]]
[TOP topExpr] [OFFSET offsetExpr]
JSON ( formName [OBJECTS objName1 = expr1, ..., objNameK = exprK]
[TOP (topExpr | (topGroupId1 = topPropertyExpr1, ..., topGroupIdT = topPropertyExprT))]
[OFFSET (offsetExpr | (offsetGroupId1 = offsetPropertyExpr1, ..., offsetGroupIdF = offsetPropertyExprF))] )
Description
The JSON operator is property that creates JSON from the specified properties or form.
When exporting a form in an OBJECTS block, it is possible to add extra filters to check for the equality of the objects on the form with the values passed. These objects will not participate in building the object group hierarchy.
Parameters
-
formNameThe name of the form from which you want to export data. Composite ID.
-
objName1 ... objNameKNames of form objects for which filtered (fixed) values are specified. Simple IDs.
-
expr1 ... exprKExpressions whose values determine the filtered (fixed) values for form objects.
-
propertyExpr1, ..., propertyExprNList of expressions from whose values the data is exported
-
columnId1, ..., columnIdNA list of column IDs in the resulting JSON into which data from the corresponding property will be exported. Each list element is either a simple ID or a string literal. If no ID is specified, it is considered equal to
expr<Column number>by default. -
whereExprAn expression whose value is a condition for the export. If not specified, it is considered equal to the disjunction of all exported properties (that is, at least one of the properties must be non-
NULL). -
orderExpr1, ..., orderExprLList of expressions by which the exported data is sorted. Only properties present in the list
propertyExpr1, ..., propertyExprNcan be used -
DESCKeyword. Specifies reverse sort order. By default, ascending sort is used.
-
TOP topExpr -
TOP (topExpr | (topGroupId1 = topPropertyExpr1, ..., topGroupIdT = topPropertyExprT))Export only first
nrecords, wherenis value of expressiontopExprortopPropertyExprTfor group objecttopGroupIdT. -
OFFSET offsetExpr -
OFFSET (offsetExpr | (offsetGroupId1 = offsetPropertyExpr1, ..., offsetGroupIdF = offsetPropertyExprF))Export only records with offset
m, wheremis value of expressionoffsetExproroffsetPropertyExprFfor group objectoffsetGroupIdF.
Examples
FORM testF
OBJECTS j = INTEGER
PROPERTIES ab='34'
OBJECTS i = INTEGER
PROPERTIES name = 'Name ' + (i AS INTEGER)
;
run() {
MESSAGE JSON (testF OBJECTS j=4 FILTERS mod(i,2) = 0);
}
MESSAGE JSON FROM code = '1', message = 'OK';