i am work on an online credit topup application. now i want to fetch the denomination available to a particular type of voucher which is select by.this is the scenario a user selects a type of voucher(tigo,mtn,vodafon,airtel etc) from a combo box.after the selection the voucher denomination combobox should be populated with all denominations available. for now am out putting with json .av tried with this code but it returns this:
@RequestMapping(value = "/rest/getdenominations")
public @ResponseBody
String getDenominationByType(ModelMap model) throws JSONException {
Long vouchertypeId = 1L;
JSONArray typeDenominationsArray = new JSONArray();
for (Voucher voucher : voucherController.getTypDenominationAvailable(vouchertypeId)) {
JSONObject voucherJSON = new JSONObject();
voucherJSON.put(" ", voucher.getDenomination());
typeDenominationsArray.put(voucherJSON);
}
return typeDenominationsArray.toString();
}
but it returns this
[{" ":10},{" ":2},{" ":1},{" ":10},{" ":2}]
what i want is that the 2 and 10 should be displayed just once. need help to this..tanx in advance