JR_STR

Table of Contents

JR_STR

Description

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

Parameters

NameDirectionDescription
siin,outJSON stream iterator to read from.
stroutDestination 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)

    JR_ARR_KV(json, "test_directories", {                                                                  \
    Str s = StrInit();                                                                                 \
    JR_STR(json, s);                                                                                   \
    VecPushBack(&p.test_directories, s);                                                               \
    });                                                                                                    \
    JR_ARR_KV(json, "source_directories", {                                                                \
    Str s = StrInit();                                                                                 \
    JR_STR(json, s);                                                                                   \
    VecPushBack(&p.source_directories, s);                                                             \
    });                                                                                                    \
    JR_ARR_KV(si, "languages", {
    Str lang = StrInit();
    JR_STR(si, lang);
    VecPushBack(&languages, lang);
    });
    JR_ARR_KV(si, "tags", {
    Str tag = StrInit();
    JR_STR(si, tag);
    VecPushBack(&product.tags, tag);
    });
    JR_ARR_KV(si, "strings", {
    Str str = StrInit();
    JR_STR(si, str);
    VecPushBack(&parsed_strings, str);
    });
    JR_ARR_KV(si, "features", {
    Str feature = StrInit();
    JR_STR(si, feature);
    VecPushBack(&parsed.config.features, feature);
    });
    JR_ARR_KV(si, "empty_strings", {
    Str str = StrInit();
    JR_STR(si, str);
    VecPushBack(&parsed_strings, str);
    });
    JR_ARR_KV(si2, "data", {
    Str value = StrInit();
    JR_STR(si2, value);
    VecPushBack(&data, value);
    });

Share :

Related Posts

JReadInteger

JReadInteger Description Strictly read an integer from input string.

Read More

JReadString

JReadString Description Read a quoted string, handling escape sequences.

Read More

JReadNumber

JReadNumber Description Read a JSON number (int or float) from input string.

Read More