-- string foo:
$processor$: get-data
-- string foo:
$processor$: get-data
Assuming foo: "hello"
is part of “data”, the variable foo
will be get “hello” as the value.
By default, the name of the variable or list where the data is being store is used as the key. You can overwrite the key using key
attribute:
-- string foo:
$processor$: get-data
key: some-other-key-instead-of-foo
-- string foo:
$processor$: get-data
key: some-other-key-instead-of-foo
If the data is not found, we use the body as default value if body is available.
-- string foo:
$processor$: get-data
"hello world"
-- string foo:
$processor$: get-data
"hello world"
The body must be valid json, compatible with the data type on which we are using the get-data
processor.
Default Value in Caption For Basic Types
For basic types like integer
, boolean
etc, the default value can also be provided in the caption. E.g.
-- string foo: hello world
$processor$: get-data
-- string foo: hello world
$processor$: get-data
Providing both body
and caption
when using get-data
is an error.
Reading data from JSON File
We will be reading the data from JSON file and injecting the value to the caller of the processor (caller could be variable or component).
Step - 1 : We need to make two files i.e. one file should be .ftd and another file should be .json
Step - 2 : Creating .ftd (for example, record.ftd)
-- record person:
caption name:
integer age:
string gender:
-- person arpita:
$processor$: get-data
file: foo.json
-- ftd.text: $foo.name
-- ftd.text: $foo.age
-- ftd.text: $foo.gender
-- record person:
caption name:
integer age:
string gender:
-- person arpita:
$processor$: get-data
file: foo.json
-- ftd.text: $foo.name
-- ftd.text: $foo.age
-- ftd.text: $foo.gender
Step - 3 : Creating .json (for example, foo.json)
{
"name": "arpita",
"age": 15,
"gender": "female"
}
{
"name": "arpita",
"age": 15,
"gender": "female"
}
Step - 4 : Output
NOTE : It will throw an error if other than .json file is used.