Insert excerpt | ||||||||
---|---|---|---|---|---|---|---|---|
|
JSON documents can be created in PhixFlow using the toJson function and the output modified using the following notations.
Table of Contents | ||||||
---|---|---|---|---|---|---|
|
Curly Brackets { }
Use curly brackets to create an object, e.g.
{ "FirstName" : "John", "LastName" : "Smith", "Age" : 50 }
Colon : and Dot .
- Use a colon to define a key-value pair, e.g.
{ "key" : "value" }
- The key must always evaluate to be a string
- The value must always evaluate to be a string, number, object, array, boolean or null
- Use a dot to access the key and value, e.g.
$foo.key:$foo.value
Example using curly brackets, colon and dot
Code Block | ||
---|---|---|
| ||
{
forEach(
//Convert the data from the lookup, getCo, to JSON and store it in the variable $company
$company, toJson(getCo),
/*Using the $company object, create a key-value pair where the key is the Company Name and the value is an object containing two key-value pairs of the CompanyID:value and Industry:value*/
$company.CompanyName : $company.CompanyID:Industry
)
} |
Code Block | ||
---|---|---|
| ||
{
"Romaguera Inc" : {
"CompanyID" : 108,
"Industry" : "Manufacturing"
},
"Becker and Sons" : {
"CompanyID" : 112,
"Industry" : "Manufacturing"
},
"Larson Inc" : {
"CompanyID" : 398,
"Industry" : "Manufacturing"
}
} |
At @ and Dollar $
- @ can be used to reference the current object
- It allows access to any key-value pairs that have already been set
- Use the syntax
@.^.
to traverse upwards
- $ can be used to reference the outer object of the current object being created
- It will allow access to any key-value pairs that have already been set
Example using @
Code Block | ||
---|---|---|
| ||
{
forEach(
$company, toJson(getCo),
$company.CompanyName : {$company,"CompanyName" : toUpper(@.CompanyName)}
)
} |
Note the use of @ as a shortcut for the current object, which is $company.
Code Block | ||
---|---|---|
| ||
{
"Romaguera Inc" : {
"CompanyID" : 108,
"CompanyName" : "ROMAGUERA INC",
"Industry" : "Manufacturing"
},
"Becker and Sons" : {
"CompanyID" : 112,
"CompanyName" : "BECKER AND SONS",
"Industry" : "Manufacturing"
},
"Larson Inc" : {
"CompanyID" : 398,
"CompanyName" : "LARSON INC",
"Industry" : "Manufacturing"
}
} |
Example using $
Code Block | ||
---|---|---|
| ||
{
"Count":2,
forEach(
$company, toJson(getCo),
$.Count : {$company,"CompanyName" : toUpper($company.CompanyName)}
)
} |
Note the use of $.Count as a shortcut for the outer object of the current object being created.
Code Block | ||
---|---|---|
| ||
{
"Count" : 2,
"2" : {
"CompanyID" : 398,
"CompanyName" : "LARSON INC",
"Industry" : "Manufacturing"
}
} |
Live Search | ||||||||
---|---|---|---|---|---|---|---|---|
|
borderColor | #00374F |
---|---|
titleColor | white |
titleBGColor | #00374F |
borderStyle | solid |
title | Sections on this page |