Hello!
(you have an error in your code sample: DEFINE json_obj
util.JSONObject)
The main purpose of TEXT/BYTE types is to store LOB (Larg OBjects) from the database, from TEXT/BYTE columns in case of Informix, and CLOB/BLOB columns for other DB engines.
As you certainly know, TEXT is for simple text data, and BYTE is for media (images, sound, proprietary doc/text formats).
Obviously, don't replace all your STRING/CHAR/VARCHAR variables by TEXT!
But yes, you can use TEXT to load text files as shown in your sample code, it's not bad practice.
Just make sure that the charset of the text file and the application correspond:
There is no automatic conversion done (that would require some meta-data info to know what is the charset of the file).
Pay attention to TEXT/BYTE variable specifics:
These are references to LOB structures.
For ex when you assign to another variable you only copy the internal handle, not the data!
You must also properly LOCATE these variable before usage.
Use FREE to release allocated resources (take care it will delete the underlying file!)
LOCATE tx IN FILE uses a temp file that is automatically deleted when program ends.
If you just want to read a file without touching it, you can directly locate the TEXT variable to that file:
LOCATE text_content IN FILE "my_config.json"
LET json_obj = util.JSONObject.parse(text_content)
DISPLAY json_obj.toString()
--FREE text_content -- FREE would delete the file!!!!
If not yet done, read carefully the documentation.
https://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_datatypes_TEXT.htmlhttps://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_datatypes_BYTE.htmlhttps://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_variables_LOCATE.htmlhttps://4js.com/online_documentation/fjs-fgl-manual-html/#fgl-topics/c_fgl_variables_FREE.htmlSeb