Open-source Languages & Tools for z/OS

 View Only
  • 1.  Curl not converting JSON or XML content types to EBCDIC

    Posted 03-15-2017 03:45

    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.



  • 2.  RE: Curl not converting JSON or XML content types to EBCDIC

    Posted 03-15-2017 08:35

    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.



  • 3.  RE: Curl not converting JSON or XML content types to EBCDIC

    Posted 03-15-2017 09:28

    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.