JSON-READ error when reading from a JSON-WRITE - Forum - OpenEdge Development - Progress Community

JSON-READ error when reading from a JSON-WRITE

 Forum

JSON-READ error when reading from a JSON-WRITE

This question has suggested answer(s)

Hi 

Please see below simple program which returns an error on the JSON-READ:

Error status  yes Error parsing JSON: expected bracket, but found brace. (15358)

This seems odd as the JSON was created from a JSON-WRITE and is valid JSON as far as i can tell.

*******************************************************************************************************************

BLOCK-LEVEL ON ERROR UNDO, THROW.
DEFINE TEMP-TABLE tt-CustomUIMessages SERIALIZE-NAME "UIMessages"
FIELD MessageNumber AS INTEGER
FIELD MessageType AS CHARACTER /* Warning, Input, Textarea, Lookup (select), Radioset */
FIELD MessageLabel AS CHARACTER
FIELD MessageValues AS CHARACTER
FIELD MessageHelp AS CHARACTER
FIELD MessageAnswer AS CHARACTER
FIELD MessageError AS CHARACTER
FIELD MessageRead AS LOGICAL
INDEX idx-primary IS PRIMARY UNIQUE MessageNumber
INDEX idx-answered MessageType MessageAnswer
INDEX idx-read MessageType MessageRead.

/* This table holds the Key / Value pairs for dropdowns / <select><option name="key">Value</option></select> */
DEFINE TEMP-TABLE tt-CustomUIMessagesValues SERIALIZE-NAME "UIMessageValues"
FIELD MessageNumber AS INTEGER SERIALIZE-HIDDEN
FIELD MessageKey AS CHARACTER
FIELD MessageValue AS CHARACTER
INDEX idx-primary IS PRIMARY UNIQUE MessageNumber MessageKey.

DEFINE DATASET UiMessages SERIALIZE-HIDDEN
FOR tt-CustomUIMessages, tt-CustomUIMessagesValues
DATA-RELATION UIMessageValue1 FOR tt-CustomUIMessages, tt-CustomUIMessagesValues RELATION-FIELDS(MessageNumber, MessageNumber) NESTED.


CREATE tt-CustomUIMessages.
ASSIGN tt-CustomUIMessages.MessageNumber = 1
tt-CustomUIMessages.MessageType = "Lookup"
tt-CustomUIMessages.MessageLabel = "WHat is the capital of England".

CREATE tt-CustomUIMessagesValues.
ASSIGN tt-CustomUIMessagesValues.MessageNumber = 1
tt-CustomUIMessagesValues.MessageKey = "LON"
tt-CustomUIMessagesValues.MessageValue = "London".

CREATE tt-CustomUIMessagesValues.
ASSIGN tt-CustomUIMessagesValues.MessageNumber = 1
tt-CustomUIMessagesValues.MessageKey = "LIV"
tt-CustomUIMessagesValues.MessageValue = "LIverpool".

DATASET UiMessages:WRITE-JSON("file", "C:\OpenEdge\WRK117_64\sample_json.txt",TRUE, ?) NO-ERROR.


DATASET UiMessages:READ-JSON("file", "C:\OpenEdge\WRK117_64\sample_json.txt","Empty") NO-ERROR.
OUTPUT TO "C:\OpenEdge\WRK117_64\sample_json.log".

MESSAGE "Error status " ERROR-STATUS:ERROR ERROR-STATUS:GET-MESSAGE(1).
OUTPUT CLOSE.

FOR EACH tt-CustomUIMessages NO-LOCK:

MESSAGE "Message Number: " tt-CustomUIMessages.MessageNumber.

END.

All Replies
  • Same here... strange bug.

    Running OpenEdge 11.7.0

  • Hi, when omitted SERIALIZE-HIDDEN from DEFINE DATASET UiMessages your example worked well.

  • My problem was the use of the DEFINE DATASET UiMessages SERIALIZE-HIDDEN.

    Removing the serialize-hidden resolved the issue e.g.

    DEFINE DATASET UiMessages

  • This is a bug.  Please log an issue with Tech Support.

    Robin