JsMakeString Method (Client)


PLB Web Only, 9.8

 

The JsMakeString method converts a PLB DIM data string into a properly formatted JSON string including UTF8 conversion and data escaping. The method uses the following format:

 

[label]

{object}.JsMakeString

[GIVING {return}] USING [*Text=]{inputstr}

 

Where:

label

Optional. A Program Execution Label.

object

Required. A CLIENT object.

return

Optional. A Character String Variable that returns the result as a properly formatted json string.

inputstr

Required. A Character String Variable or literal that contains the input PLB string to be converted into a JSON string.

Flags Affected: EOS, OVER, ZERO

Note the following:

  1. The EOS flag is set TRUE if the return variable is too small to receive the JSON string result without being truncated.

  2. The ZERO flag is always cleared.

  3. The OVER flag is always cleared.

  4. The {return} string is always generated with a leading and trailing double quote character (i.e. '"').

  5. Any embedded '\' or '"' characters in the {inputstr} data is escaped with a leading '\' character.

  6. Any characters in the {inputstr} with a character value than 0x7F are converted to an UTF8 sequence.

  7. Any characters in the {inputstr} with a value less than 0x20 are converted to a 0x20 value except for the following characters:

  8.  

    0x08 - '\b'

    0x0A - '\n'

    0x0D - '\r'

Example

 

A INIT "Hello World"

B INIT "Hi there #"Bill#"!"

C INIT 0x08, 0x0D, 0x0A

RESDATA DIM 50

CL CLIENT

         ...

        CL.JsMakeString GIVING RESDATA USING A

        DISPLAY "A--->",*ll, RESDATA, "<---"

.

        CL.JsMakeString GIVING RESDATA USING B

        DISPLAY "B--->",*ll, RESDATA, "<---"

.

        CL.JsMakeString GIVING RESDATA USING C

        DISPLAY "C--->",*ll, RESDATA, "<---"

.

        KEYIN "Hit enter to exit: ", A

.

        STOP

 

 

See Also: CLIENT, Client Methods, Method Syntax

 



PL/B Language Reference GetWinInfo Method (CLIENT) JqGet Method (CLIENT)