MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / json_get_int

Function json_get_int

src/pipeline/pass_complexity.c:47–62  ·  view source on GitHub ↗

Parse an integer "key":N from a flat JSON object. Returns def if absent. */

Source from the content-addressed store, hash-verified

45
46/* Parse an integer "key":N from a flat JSON object. Returns def if absent. */
47static int json_get_int(const char *json, const char *key, int dflt) {
48 if (!json) {
49 return dflt;
50 }
51 char pat[CBM_SZ_64];
52 snprintf(pat, sizeof(pat), "\"%s\":", key);
53 const char *p = strstr(json, pat);
54 if (!p) {
55 return dflt;
56 }
57 p += strlen(pat);
58 while (*p == ' ' || *p == '\t') {
59 p++;
60 }
61 return (int)strtol(p, NULL, CBM_DECIMAL_BASE);
62}
63
64/* Parse a boolean "key":true/false from a flat JSON object. */
65static bool json_get_bool(const char *json, const char *key) {

Callers 1

tld_seedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected