here an example how to create from x++ a simple json object.
static void JobEF_ListToJson(Args _args)
{
int i;
str myJson;
System.Web.Script.Serialization.JavaScriptSerializer ser = new System.Web.Script.Serialization.JavaScriptSerializer();
System.Object oVar;
System.Type listType = System.Type::GetType('System.Collections.ArrayList');
CLRObject arrayList = System.Activator::CreateInstance(listType);
new InteropPermission(InteropKind::ClrInterop).assert();
for( i = 0; i <= 5 ; i++)
{
oVar = strFmt('%1 is the value %2', i, DateTimeUtil::utcNow());
arrayList.Add(oVar);
}
myJson = ser.Serialize(arrayList);
info(myJson);
}
No comments:
Post a Comment