Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

JSON Utilities

2020-03-19
2022-04-24
  • jeremyshubert - 2020-03-19

    JSONByteArrayWriter appears to add a carriage return and line feed between each each JSON element. How can this be removed?

     
  • koppit - 2022-04-24

    I have run into the same issue. Zigbee2MQTT does not like newline and carrige return.
    I was hoping it was as easy as a configuration, but I can't find it.
    I have just done a pass over the string to remove unwanted whitespace.

    IF Finalize_JSON THEN
    
            // Remove Carrige Return and New Line from json
            WHILE 0 <> WFIND(payload.str, "$R$N") DO
                payload.str := WDELETE(payload.str, 2, WFIND(payload.str, "$R$N"));
            END_WHILE;
    
            // Remove triple spaces
            WHILE 0 <> WFIND(payload.str, "   ") DO
                payload.str := WDELETE(payload.str, 3, WFIND(payload.str, "   "));
            END_WHILE;
    
            Finalize_JSON := FALSE;
    
        END_IF;
    
     

Log in to post a comment.