I have a JSON element that will contain some Y/N flags, but there can be embedded blanks in the string.
"Flags": "YNNYN Y"
My data structure allows a string of up to 40 characters:
DS
Flags char(40);
My issue is that after the Data-Into the value in Flags is this:
Flags = 'YNNYN Y '
It has compressed all the extra spaces and only leaves one.
I've done other tests and the results are similar.
"Flags": "A B C D"
after the Data-Into
Flags = 'A B C D '
I did try using the yajl_object_find and yajl_get_string and it retains the exact same string from the JSON (no compression).
Has anyone else run into this behavior? I thought everything inside the double quotes would be preserved exactly as it was presented in the JSON.
Data-Into loses embedded blanks
-
- Site Admin
- Posts: 872
- Joined: Sun Jul 04, 2021 5:12 am
Re: Data-Into loses embedded blanks
Hiya Alan,
Thanks for reaching out. The RPG DATA-INTO opcode has an option called 'trim' that can be used to trim blanks. I'm referring to the TRIM option of the %DATA built-in function (not to be confused with the %TRIM built-in function.)
Many people don't realize that in addition to trimming off the leading/trailing blanks, it also consolidates the blanks in the middle of strings.
Details here:
https://www.ibm.com/docs/en/i/7.4?topic ... ll#trimopt
If you set it to trim=none, it should stop trimming them. (You may have to trim leading/trailing blanks manually if desired.)
Thanks for reaching out. The RPG DATA-INTO opcode has an option called 'trim' that can be used to trim blanks. I'm referring to the TRIM option of the %DATA built-in function (not to be confused with the %TRIM built-in function.)
Many people don't realize that in addition to trimming off the leading/trailing blanks, it also consolidates the blanks in the middle of strings.
Details here:
https://www.ibm.com/docs/en/i/7.4?topic ... ll#trimopt
If you set it to trim=none, it should stop trimming them. (You may have to trim leading/trailing blanks manually if desired.)