If you are using the Kony service editor, parse the output according to your requirement. By parsing the result one can isolate the required parameter -i.e.: Filter the result returned from service- that are only required at the client side and in a format that we can specify.
If you have three labels in the segment and you want to show the passengers
details return by the service, please follow these steps:
- Parse your JSON data, while mentioning the
id
in the service editor, please keep in mind to use the id
of the children widgets of the segment as the id
for output parameter.
- After parsing the you must get a collection which is similar as following
[
{ "labelOneId": "RAC1 , 8,GN ", "labelTwoId": " CNF 1", "labelThreeId": "Passenger 1" },
{ "labelOneId": "RAC2 , 8,GN ", "labelTwoId": " CNF 2", "labelThreeId": "Passenger 2" },
{ "labelOneId": "RAC3 , 8,GN ", "labelTwoId": " CNF 3", "labelThreeId": "Passenger 3" },
{ "labelOneId": "RAC3 , 8,GN ", "labelTwoId": " CNF 4", "labelThreeId": "Passenger 4" }
]
Where the labelOneId
, labelTwoId
and labelThreeId
will be the ids used for children of the segment where the data need to be displayed.
- After this use the set data method of the Kony.ui.segment widget to set the data.
Note: If you did not use the id of the children widget then you will have to format the data using a "for" loop iterator.
Extracting the value from the sample value provided in your question:
var jsonReturned={
"chartStat": " CHART NOT PREPARED ",
"passengers": [{
"trainBookingBerth": "RAC9 , 8,GN ",
"trainCurrentStatus": " CNF ",
"trainPassenger": "Passenger 1"
}],
"trainBoard": "Kovilpatti",
"trainBoardCode": "CVP",
"trainDest": "Chennai Egmore"
};
var oneVal = jsonReturned["passengers"]["0"]["trainBookingBerth"];
var twoVal = jsonReturned["passengers"]["0"]["trainCurrentStatus"];
var threeVal = jsonReturned["passengers"]["0"]["trainPassenger"];
var fourVal = jsonReturned["trainBoard"];
var fiveVal = jsonReturned["trainDest"];
var dataForSegment = [{
"labelOneId": oneVal,
"labelTwoId": twoVal,
"labelThreeId": threeVal,
"lableFourId": fourVal,
"labelFiveId": fiveVal
}];
Try setting this in the as the dataForSegment
as segment data. If you want to add any additional value you have to similarly extract the data from the JSON object and form a collection suitable for your segment.