JReadString

Table of Contents

JReadString

Description

Read a quoted string, handling escape sequences.

Note

Unicode escape sequences like \uXXXX are not supported.

Parameters

NameDirectionDescription
siinCurrent reading position in input string
stroutOutput string to store parsed result

Success

Returns StrIter advanced past closing quote

Failure

Returns original StrIter on error (invalid escape, missing quote, etc.)

Usage example (Cross-references)

    
    // key start
    read_si = JReadString(si, &key);
    if (read_si.pos == si.pos) {
    LOG_ERROR("Failed to read string key in object. Invalid JSON");
    }
    
    StrIter JReadString(StrIter si, Str *str) {
    if (!StrIterRemainingLength(&si)) {
    return si;
    StrIter before_si = si;
    Str     s         = StrInit();
    si                = JReadString(si, &s);
    StrDeinit(&s);
    do {                                                                                                               \
    Str my_str = StrInit();                                                                                        \
    si         = JReadString((si), &my_str);                                                                       \
    (str)      = my_str;                                                                                           \
    } while (0)
    if (!StrCmpZstr(&key, (k))) {                                                                                  \
    Str my_str = StrInit();                                                                                    \
    si         = JReadString((si), &my_str);                                                                   \
    (str)      = my_str;                                                                                       \
    }                                                                                                              \
    \
    /* key start */                                                                                            \
    read_si = JReadString(si, &key);                                                                           \
    if (read_si.pos == si.pos) {                                                                               \
    LOG_ERROR("Failed to read string key in object. Invalid JSON");                                        \

Share :

Related Posts

BitVecToStr

BitVecToStr Description Convert bitvector to string representation. Each bit becomes ‘1’ or ‘0’ character. Caller must free the returned string.

Read More

StrWriteFmtInternal

StrWriteFmtInternal Description Print out a formatted string with rust-style placeholders to given string o.

Read More

ZstrLen

ZstrLen Description Get length of a null-terminated string.

Read More