web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Serialize Json with data from an Array(collection class) in D365FO

Chaitanya Golla Profile Picture Chaitanya Golla 17,225

Hi,

Earlier I provided code where we constructed Json by extracting values from a table (CustTable), but this may not be better choice if we have to serialize hundreds of  data values. In such a case, below code would help us.

 
class CG_SerializeJsonFromArray
{       
    /// <summary>
    /// Runs the class with the specified arguments.
    /// </summary>
    /// <param name = "_args">The specified arguments.</param>
    public static void main(Args _args)
    {    
        str     json;
        Array   values = new Array(Types::String);
 
        values.value(1, "ItemA"); 
        values.value(2, "ItemB");
        values.value(3, "ItemC");
        values.value(4, "ItemD");
 
        json = FormJsonSerializer::serializeClass(values);
        info(strFmt("%1", json));
    }
 
}

Output: https://drive.google.com/open?id=15yXI2vEHQajH60qA_Sg5nq3nfHaHa8Zj

Regards,

Chaitanya Golla

Comments

*This post is locked for comments