IBM Support

SyntaxError: JSON.parse: unexpected character when processing JSON files

Question & Answer


Question

Why am I receiving a parsing error while processing my JavaScript Object Notation (JSON) files? When migrating to OSGi bundles in CICS Transaction Server for z/OS (CICS TS) V5.2, a parsing error occurs while processing JSON files. Looking at the resulting characters, the values are diaeresis and Y acute, where what is expected are left and right square brackets.

The error I see in the log is:

SyntaxError: JSON.parse: unexpected character at line 1 column 13 of the JSON data

Answer

Mainframes historically used codepage 037. Java is uses the 1047 codepage. The hex digits for right and left brackets, respectively, in codepage 037 will match the 'diaeresis' and 'Y acute' in codepage 1047.

If you are running DFHLS2JS, the output JSON schema will use the codepage 1047...and the square brackets are NOT in the same place with 037 versus 1047.

Adding LOCALCCSID=1047 to the region's system initialization table (SIT) should allow the proper conversion of the characters.

Whenever there is a parsing error with odd characters observed, it is worth looking at the codepages involved. For this problem, looking at the respective symbol values shows the following:

in codepage 1047 (native java):

     symbol       unicode    hex
   right bracket    189      BD
   left bracket     173      AD
   diaeresis        187      BB
   Y acute          186      BA

in codepage 037:

     symbol       unicode    hex
   right bracket    187      BB
   left bracket     186      BA
   diaeresis        189      BD
   Y acute          173      AD

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSGMGV","label":"CICS Transaction Server"},"Platform":[{"code":"PF035","label":"z\/OS"}],"Component":"Java","Version":"","Line of Business":{"code":"LOB35","label":"Mainframe SW"}}]

Product Synonym

CICS/TS CICSTS CICS TS CICS Transaction Server

Document Information

Modified date:
14 December 2016

UID

dwa1328248