Hi All,
I am trying to execute a query on one my ACC tables. I need to create an array of Json objects . Can someone help to do it dynamically if he has already done in the past
Table Structure :
Country | Service1 | Service2 | Service3 |
India | Yes | No | No |
Malaysia | No | Yes | Yes |
Output that I am looking for :
[
{ Country:"India",
Service1:Yes
Service2:No
Service3:No},
{ Country:"Malaysia",
Service1:No
Service2:Yes
Service3:Yes}
]
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
You can try the below code for your requirement.
var schemaName = vars.targetSchema.substr(vars.targetSchema.indexOf(":") + 1);
logInfo(schemaName);
var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="@country"/>
<node expr="@Service1"/>
<node expr="@Service2"/>
<node expr="@Service3"/>
</select>
</queryDef>
);
var resultSet = query.ExecuteQuery();
var Data='';
for each (var row in resultSet)
{
Data= Data +
"{
Country ="+row.@country;
"Service="+row.@Service1;
"Service="+row.@Service2;
"Service="+row.@Service3;
"}";
}
Data="["+Data+"]";
logInfo(Data);
You can try the below code for your requirement.
var schemaName = vars.targetSchema.substr(vars.targetSchema.indexOf(":") + 1);
logInfo(schemaName);
var query = xtk.queryDef.create(
<queryDef schema={vars.targetSchema} operation="select">
<select>
<node expr="@country"/>
<node expr="@Service1"/>
<node expr="@Service2"/>
<node expr="@Service3"/>
</select>
</queryDef>
);
var resultSet = query.ExecuteQuery();
var Data='';
for each (var row in resultSet)
{
Data= Data +
"{
Country ="+row.@country;
"Service="+row.@Service1;
"Service="+row.@Service2;
"Service="+row.@Service3;
"}";
}
Data="["+Data+"]";
logInfo(Data);
Thank you Akshay , This worked. !
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies