Skip to content

JR_STR

Description

Read a JSON string value from stream and assign to target. The resulting string is dynamically allocated in Str format.

Parameters

Name Direction Description
si in,out JSON stream iterator to read from.
str out Destination Str to store the string.

Usage example (from documentation)

  JR_STR(si, name);

Success

str contains the read string

Failure

si updated to failure state on parse error

Usage example (Cross-references)

Usage examples (Cross-references)
        } while (0)
    
    #undef JR_STR
    #define JR_STR(si, str)                                                                                                \
        do {                                                                                                               \
    
    #undef JR_STR
    #define JR_STR(si, str)                                                                                                \
        do {                                                                                                               \
            Str UNPL(my_str) = StrInit(&alloc);                                                                            \
            JR_ARR_KV(si2, "data", {
                Str value = StrInit(&alloc);
                JR_STR(si2, value);
                VecPushBack(&data, value);
            });
            JR_ARR_KV(si, "languages", {
                Str lang = StrInit(&alloc);
                JR_STR(si, lang);
                VecPushBack(&languages, lang);
            });
            JR_ARR_KV(si, "tags", {
                Str tag = StrInit(&alloc);
                JR_STR(si, tag);
                VecPushBack(&product.tags, tag);
            });
            JR_ARR_KV(si, "strings", {
                Str str = StrInit(&alloc);
                JR_STR(si, str);
                VecPushBack(&parsed_strings, str);
            });
                JR_ARR_KV(si, "features", {
                    Str feature = StrInit(&alloc);
                    JR_STR(si, feature);
                    VecPushBack(&parsed.config.features, feature);
                });
            JR_ARR_KV(si, "empty_strings", {
                Str str = StrInit(&alloc);
                JR_STR(si, str);
                VecPushBack(&parsed_strings, str);
            });
Last updated on