Share this page

# blazor_convert_from_formatted

Encodes one or more human-readable JSON messages into a MessagePack buffer.

## C Language

int blazor_convert_from_formatted("FormattedData=<json_message>", ["<json_message>", ...] "TargetParam=<parameter_name>", LAST );

Blazor - Web Functions

Argument | Description
--- | ---
FormattedData | The first JSON message to encode. The value must contain valid JSON.
[Additional JSON messages] | Optional JSON messages to encode after `FormattedData`. Additional messages do not use the `FormattedData=` prefix.
TargetParam | The name of the parameter that stores the encoded MessagePack buffer. If the parameter name starts with `SIGNALR_MSGPCK_BUFFER`, each encoded message is prefixed with its byte size to match standard SignalR behavior.
LAST | A marker indicating the end of the argument list.

## Return Values

This function stores the encoded JSON in the target parameter.

## Parameterization

Standard parametrization can be used for the first argument, `FormattedData=`.

If you add additional, optional arguments, standard parametrization will not work, but you can use `lr_eval_string("{parameter}")`. See the example, below.

## General Information

- The blazor_convert_from_formatted function is auto-generated during recording. It can also be called manually.

- When you pass multiple JSON messages, the function encodes each message separately and concatenates the resulting buffers.

- When concatenating multiple messages, use SIGNALR_MSGPCK_BUFFER as the target, so that each message includes its size. This is required for decoding later.

## Examples

The following example encodes one JSON message into a MessagePack buffer without a size prefix.

Copy code

    blazor_convert_from_formatted(
        "FormattedData=[\"BlazorWeb\"]",
        "TargetParam=MSGPCK_BUFFER_1",
        LAST);

    /* MSGPCK_BUFFER_1 = \x91\xA9\x42\x6C\x61\x7A\x6F\x72\x57\x65\x62 */

The following example encodes one JSON message into a SignalR buffer with a byte-size prefix.

Copy code

    blazor_convert_from_formatted(
        "FormattedData=[\"BlazorWeb\"]",
        "TargetParam=SIGNALR_MSGPCK_BUFFER_1",
        LAST);

    /* SIGNALR_MSGPCK_BUFFER_1 = \x0B\x91\xA9\x42\x6C\x61\x7A\x6F\x72\x57\x65\x62 */

The following example encodes two JSON messages and concatenates them into one SignalR buffer.

Copy code

    blazor_convert_from_formatted(
        "FormattedData=[\"BlazorWeb\"]",
        "[\"BlazorWebAnotherMessage\"]",
        "TargetParam=SIGNALR_MSGPCK_BUFFER_1",
        LAST);

    /* SIGNALR_MSGPCK_BUFFER_1 = \x0B\x91\xA9\x42\x6C\x61\x7A\x6F\x72\x57\x65\x62\x19\x91\xB7\x42\x6C\x61\x7A\x6F\x72\x57\x65\x62\x41\x6E\x6F\x74\x68\x65\x72\x4D\x65\x73\x73\x61\x67\x65 */

The following example shows use of lr_eval_string for parameterization of additional arguments.

Copy code

    blazor_convert_from_formatted(
      "FormattedData={NewParam}", lr_eval_string("{NewParam}"),
      "TargetParam=SIGNALR_MSGPCK_BUFFER_1",
    LAST);

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: