Notifications
Announcements
No record found.
Hi All,
How could i iterate the data contract class ?
MyDataContractClass myDataContractClass = FormJsonSerializer::deserializeObject(classNum(MyDataContractClass),responseJson); [DataContractAttribute] class MyDataContractClass { String50 invoiceId, profBillId, status, message; [DataMemberAttribute('proformaId')] public String50 parmProfBillId(String50 _profBillId = profBillId) { profBillId = _profBillId; return profBillId; } [DataMemberAttribute('invoiceId')] public String50 parmInvoiceId(String50 _invoiceId = invoiceId) { invoiceId = _invoiceId; return invoiceId; } [DataMemberAttribute('status')] public String50 parmStatus(String50 _status = status) { status = _status; return status; } [DataMemberAttribute('error')] public String50 parmMessage(String50 _message = message) { message = _message; return message; } }
Thanks,
Masha
Hi Masha,
Do you want to iterate over parm methods from contract class?
Hi Sergei,
yeah , i tried to deserialized the response json i get to data contract class and then want to iterate that.
You can use Dict* classes to iterate over members of the contract class. But what is the purpose of that iteration? You have only 4 members in your class.
SysDictClass contractDictClass = new SysDictClass(your contract class id); Set methods = contractDictClass.methods(true, false, true); SetEnumerator methodsEnumerator = methods.getEnumerator(); while(methodsEnumerator.moveNext()) { DictMethod dictMethod = methodsEnumerator.current(); DataMemberAttribute dataMember = dictMethod.getAttribute(classStr(DataMemberAttribute)); if (dataMember) { // Do something } }
Hi sergei,
for the example, i get this json response
[ { "proformaId": "XXX", "invoiceId": "YYY", "error": "Unit not exists", "status": "failed" }, { "proformaId": "ZZZ", "invoiceId": "AAA", "status": "success" } ]
and want to iterate that into my data contract class attribute
So you have several entries in JSON and want them all to be converted to contract. In this case, you need to use deserializeCollection method
List collection = FormJsonSerializer::deserializeCollection(classNum(List), json_string, types::Class, classStr(MyContract));
Thanks a lot, really appreciate for your help
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 646 Most Valuable Professional
André Arnaud de Cal... 529 Super User 2025 Season 2
Sohaib Cheema 285 User Group Leader