I tried to use curl to call a REST API that returns a JSON payload. The response was not converted to EBCDIC. I tried with an XML response which was the same. I’m assuming that curl uses the MIME type to figure out what to convert. So any text/* MIME types get correctly converted. I would suggest application/json should also be converted which by the standard is UTF8 encoded. application/xml is different as XML can be in any encoding but I would take a punt and also convert it to EBCDIC.
Hi, David. I don’t know if the behavior you are seeing is intentional or accidental, but it seems to me to be the correct behavior. Since both JSON and XML are UTF-8 friendly, unconditional conversion to EBCDIC (or any other 8-bit encoding) is potentially an information-damaging conversion.
Hey Jerry. That’s a reasonable answer but I’m not sure if it’s true for JSON. I’ve ported several JSON parsers to z/OS and any non-ASCII characters (>0x7F) get escaped. When you consider how pervasive JSON is now with APIs IMO a z/OS port of curl should convert to EBCDIC. If not implicitly then a flag would be good so one doesn’t need to pipe it through iconv. The trouble with iconv is that if you want to also include headers it will mangle them.