Skip to content

JReadString

JReadString

Description

Read a quoted string, handling escape sequences.

Unicode escape sequences like \uXXXX are not supported.

Parameters

Name Direction Description
si in Current reading position in input string
str out Output 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)

Usage examples (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");                                        \
Last updated on