Deserialize Json build from a List collection class in D365FO
Views (1772)
Hi,
In this post we will see the process of deserializing Json build from an array of values. For demo purpose, I build a list with set of values using List collection class, serialized json string with them and deserialized json string.
Runnable Class: CG_DeSerializeJsonFromList
class CG_DeSerializeJsonFromList
{ /// <summary> /// Runs the class with the specified arguments. /// </summary> /// <param name = "_args">The specified arguments.</param> public static void main(Args _args) { str json; List values = new List(Types::String); ListEnumerator value; values.addStart("ItemA"); values.addEnd("ItemB"); values.addEnd("ItemC"); values.addEnd("ItemD"); // Serializing Json json = FormJsonSerializer::serializeClass(values); // Deserializing Json values = FormJsonSerializer::deserializeCollection(classnum(List), json, Types::String); value = values.getEnumerator(); while(value.moveNext()) { info(strFmt("Value: %1", value.current())); } } }Output: https://drive.google.com/open?id=1F-o2JgsNk5Xv_KDK1Q4issXySp192zd6
Regards,
Chaitanya Golla

Like
Report
*This post is locked for comments