JSON Parse Issue. Not recognizing {

I am receiving this with my cobol JSON parse;

“X’C0’ found but expecting left Curly bracket. “

X’C0’ is the hex form of { What am I doing wrong in the JSON parse?

Shouldn’t that be “0xC0”?

Hi CraigB,

Are you sure you are using the correct character encoding format?
E.g. at my work we use IBM277 EBCDIC, and { is X’9C’ in that format.

/Rune

If you’ve run your code through a JSON validator and it is verified to be correct, like Rune mentioned, this could be a code page issue. If your JSON is not coming into your program in UTF-8 format, you will need to convert it to that format first before it is used in ‘json parse’. If you are coding the JSON by hand in your program, it will likely be in EBCDIC codepage 1140. You must first convert it to EBCDIC codepage 1047 and then from there it can be converted to UTF-8 (codepage 1208), something like this:

Move function display-of(
  function national-of(json-doc 1047) 1208) to
  json-doc-1208(1:function length(json-doc))
Json parse json-doc-1208 into inv-data
with detail
end-json

See this kind of conversion in a larger example at IBM Docs