All posts by Philippe

Add systematically jsonClass=\”array\” tag to entities with componentToStruct statement

To export a component in a JSON stream, we have to flag each entity wjth the jsonClass=\”array\” tag before the statement strucToJson.

For example, if we have to nested entities ENT1.MOD1 and ENT2.MOD2 we must do the following sequence of statement for having a valid JSON:

componenttostruct lvS
lvS->ENT1.MOD1->$tags->jsonClass=\”array\”
lvS->ENT1.MOD1->OCC->ENT2.MOD1->$tags->jsonClass=\”array\”
structtoJSON lvJSON, lvS

We obtain the following JSON stream, which is correct:

{
\”ENT1.MOD1\” : [
{
\”ENT2.MOD1\” : [
{
\”F1\” : \”A\”,
\”F2\” : \”B\”,
\”F3\” : \”C\”
},
{
\”F1\” : \”D\”,
\”F2\” : \”E\”,
\”F3\” : \”F\”
},
{
\”F1\” : \”G\”,
\”F2\” : \”H\”,
\”F3\” : \”I\”
}
]
}
]
}

Component serialization

It would be nice, with stateless component to have a simply way to store and load component state.
Introduction of structs in 9.5 made this easily possible:

;Trigger Set State

componentToStruct lvStruct, \”ROOT_ENTITY.MODEL\”
structToXml lvXml, lvS
; Store somewhere lvXml

;Trigger Get State

; restore lvXml from somewhere
xmlToStruct lvStruct, lvXml
structToComponent lvStruct->ROOT_ENTITY.MODEL

But with E113 patch it\’s non longer possible because type date fields are converted, during structToXml, in yyyy-mm-dd format and are not understood as date in structToComponent instruction, unless using an xsd schema in xmlToStruct, which is unfortunate.

Perhaps a simple /string switch for the structToXml instruction to not convert type in XML type will be sufficient.

Name-spaces for Proc Library

To avoid collisions between entry names after including a proc library into a component, need a name-space to call them. Like in python language, it could be nice to have a #import directive instead of a #include. So, an entry could be compiled with LibraryName:EntryName and then could be invoke with call LibraryName:EntryName(Args) like global Proc.