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
JSON is alternative to structures in Dashboard projects (for now, JSON is only supported in Dashboard projects!). Structure has fixed set of fields which must be specified during the development time. In the runtime you can't extend a structure value with a new filed name. Contrary to that, JSON values are completely open, you don't need to specify its structure during development and you can build arbitrary JSON values during the runtime. We can say that structures are statically typed and JSON is dynamically typed.
Add json variable type
Support JSON literal in expressions. Syntax is json`...` or JSON`...` (instead of quotes, a backtick character is used), for example:
Allow ObjectExpression to construct JSON values [1].
Add JSON.get function. For example: Flow.get(json_value, "c.arr.0")
Add JSON.clone function to make a deep clone/copy of the existing JSON object.
JSON members should be possible to be accessed like struct and array members. For example: json_value.c.arr[0]
Support assigning value to JSON member using SetVariable action.
Array.length, Array.append, Array.insert and Array.remove support for JSON
JSONParse should output json value by default.
[1] JSON values can be constructed using EEZ Flow Expression by using either JSON literal or ObjectExpression construct. For example, the following expressions will construct the same JSON value:
by using JSON literal: json`{ "a": 1 }`
or by using ObjectExpression: { a: 1 }
As you can see, ObjectExpression is simpler because no quotes are required for the property names. Also, in ObjectExpression for the property values you can use other expressions where for the JSON literals you must only use literal values. For example this is allowed:
{
a: int_var
}
wher int_var is for example local variable.
But, you can't do the same with JSON literal:
// This is not valid expression!!!
json`{
"a": int_var
}`
The text was updated successfully, but these errors were encountered:
mvladic
changed the title
[Dashboard] A new variable type for JSON values and other improvements
[Dashboard] A new variable type for JSON values and other JSON improvements
May 23, 2024
JSON is alternative to structures in Dashboard projects (for now, JSON is only supported in Dashboard projects!). Structure has fixed set of fields which must be specified during the development time. In the runtime you can't extend a structure value with a new filed name. Contrary to that, JSON values are completely open, you don't need to specify its structure during development and you can build arbitrary JSON values during the runtime. We can say that structures are statically typed and JSON is dynamically typed.
json
variable typejson`...`
orJSON`...`
(instead of quotes, a backtick character is used), for example:JSON.get
function. For example:Flow.get(json_value, "c.arr.0")
JSON.clone
function to make a deep clone/copy of the existing JSON object.json_value.c.arr[0]
Array.length
,Array.append
,Array.insert
andArray.remove
support for JSON[1] JSON values can be constructed using EEZ Flow Expression by using either JSON literal or ObjectExpression construct. For example, the following expressions will construct the same JSON value:
json`{ "a": 1 }`
{ a: 1 }
As you can see, ObjectExpression is simpler because no quotes are required for the property names. Also, in ObjectExpression for the property values you can use other expressions where for the JSON literals you must only use literal values. For example this is allowed:
wher
int_var
is for example local variable.But, you can't do the same with JSON literal:
The text was updated successfully, but these errors were encountered: