Title: ATTRIBUTE or ATTRIBUTES Post by: Benjamin G. on October 03, 2024, 11:43:01 am Hi,
Look at this 4gl codes (tested version 4 and 5) : 1/ DEFINE jdb RECORD ATTRIBUTES(json_name="database") rec_tlsbonret DYNAMIC ARRAY ATTRIBUTE(json_name="tlsbonret_2") OF t_tlsbonret ,rec_tlsclidis DYNAMIC ARRAY ATTRIBUTES(json_name="tlsclidis_2") OF t_tlsclidis END RECORD DISPLAY util.JSON.stringify(jdb) It seems that you can use the two syntax ATTRIBUTE or ATRIBUTES and it's works. 2/ This syntax is accepted by the compiler but at runtime ATTRIBUTE(S) are ignored ... DEFINE jdb RECORD ATTRIBUTES(json_name="database") rec_tlsbonret DYNAMIC ARRAY OF t_tlsbonret ATTRIBUTE(json_name="tlsbonret_2") ,rec_tlsclidis DYNAMIC ARRAY OF t_tlsclidis ATTRIBUTES(json_name="tlsclidis_2") END RECORD DISPLAY util.JSON.stringify(jdb) Regards Title: Re: ATTRIBUTE or ATTRIBUTES Post by: Sebastien F. on October 03, 2024, 02:58:59 pm Hello Benjamin,
1/ The fglcomp compiler considers ATTRIBUTE and ATTRIBUTES as synonyms (I would say for backward compatibility) We have only documented the second keyword, because you can specify multiple attributeS in this clause. If some consider that we should document both keywords, the syntax diagram would look like this: Code: ATTRIBUTE[S] ( attribute [ = "value" ] [,...] ) or Code: {ATTRIBUTE|ATTRIBUTES} ( attribute [ = "value" ] [,...] ) instead of current simple diagram: Code: ATTRIBUTES ( attribute [ = "value" ] [,...] ) https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_variables_attributes.html If we document both, programmers will tend to use sometimes ATTRIBUTE and sometime ATTRIBUTES, with the risk to miss one or the other when searching in your code ( vim ctrl-* ) Return to simplicity. 2/ In JSON, array elements have no name. Try to put the ATTRIBUTES() clause just after DYNAMIC ARRAY: Code
output (with my own t_tlsbonret and t_tlsclidis types): Code: { Seb Title: Re: ATTRIBUTE or ATTRIBUTES Post by: Benjamin G. on October 03, 2024, 03:11:29 pm Hi,
for the point "2" i think that compiler must be at least "warn" the user because the syntax will not produce the good result ... Regards Title: Re: ATTRIBUTE or ATTRIBUTES Post by: Sebastien F. on October 04, 2024, 09:34:06 am Hello,
1/ After a discussion with the team we will document ATTRIBUTE and ATTRIBUTES as synonyms. 2/ Sometimes the ATTRIBUTE/ATTRIBUTES clause can be used at the array element level: See this: Code
Title: Re: ATTRIBUTE or ATTRIBUTES Post by: Benjamin G. on October 04, 2024, 09:48:00 am Hi,
the second example should be included in the documentation Regards Title: Re: ATTRIBUTE or ATTRIBUTES Post by: Reuben B. on October 06, 2024, 10:40:35 pm Hi, the second example should be included in the documentation Regards ... I did write an article on that about six/seven months ago after we had a couple of support calls all falling into the same trap https://4js.com/ask-reuben/ig-217/ |