|
Hmmm. I am not sure what I am missing here but I have a program that is
reading data into a data structure and then later I output that data
into a stream file in the IFS. I am formatting the data into a JSON
string and use the curly braces to begin and end each record. But is
seems that the double quote plus a right curly brace e.g. "} ends up
as a special character and doesn't end up as a correctly formatted string.
I am using the following D specs to set the values:
D q S 1A Varying
D Inz('"')
D c S 1A Varying
D Inz(',')
D sc S 3A Varying
D Inz('":"')
D lb S 1A Varying
D Inz('{')
D rb S 1A Varying
D Inz('}')
D lc S 1A Varying
D Inz(' ')
and in the code I concatenate the values into a string that is written
to the IFS. The formatting looks like this:
Line = lc + lb + q + 'msgtxt' + sc + msgtxt + q + c +
q + 'msgid' + sc + RCVM0200.MsgID + q + c +
q + 'jobName' + sc + RCVM0200.SndJobNam + q + c +
q + 'jobUser' + sc + RCVM0200.SndJobUsr + q + c +
q + 'jobNumber' + sc + RCVM0200.SndJobNbr + q + rb ;
it is that final +q+rb which is the literal combination "} that causes
the heartburn. Otherwise the line formats correctly.
The output is something like this: (wrapped so it will fit here)
{"msgtxt":"Job 586612/PETE/QDFTJOBD completed normally on 04/12/11 at
18:05:55.",
"msgid":"CPF1241","jobName":"QDFTJOBD ",
"jobUser":"PETE ",""jobNumber":"586612 ½,
Notice the '1/2' symbol at the end. It *should* be "} so that the
string would look like this:
{"msgtxt":"Job 586612/PETE/QDFTJOBD completed normally on 04/12/11 at
18:05:55.",
"msgid":"CPF1241","jobName":"QDFTJOBD ",
"jobUser":"PETE ",""jobNumber":"586612"},
Should I use a different technique for the literals?
Ideas how how to work around the issue would be welcome.
--
Pete Helgren
Value Added Software, Inc
www.asaap.com
www.opensource4i.com
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.