文件
ParlzPackageManger/src/json.h
T
JGZYES 114ef62dd9 ParlzPackageManger (PMM): cross-platform package manager + mirror
- C11, static MinGW build, single exe (pmm/pdm)
- apt-style multi-mirror install with sha256/sha1 verify
- .pdm package format (pdm pack/install/remove), deb-like
- github/gitlab/gitea/forgejo release install with --git/--github etc.
- python/pip-style version selection (==,>=,<=,>,< , comma)
- auto platform selection (windows/linux variants)
- Windows Installed Apps registration + PATH auto-add
- download progress bar (tqdm-style, ASCII-safe)
- mirror/ : zero-dep Node.js registry server (variants, multi-version)
- Licensed under GNU GPL v3
2026-08-30 18:11:21 +08:00

32 行
1.0 KiB
C

/* json.h - minimal JSON parser for PMM */
#ifndef PMM_JSON_H
#define PMM_JSON_H
typedef enum {
JSON_NULL, JSON_BOOL, JSON_NUMBER, JSON_STRING, JSON_ARRAY, JSON_OBJECT
} JsonType;
typedef struct JsonValue JsonValue;
struct JsonValue {
JsonType type;
int boolean;
double number;
char *string; /* decoded string (JSON_STRING) */
JsonValue **items; /* array/object members (values) */
char **keys; /* object member keys */
int count;
int capacity;
};
JsonValue *json_parse(const char *text);
JsonValue *json_parse_file(const char *path);
void json_free(JsonValue *v);
/* Object member lookup by key; returns NULL if missing or not an object. */
JsonValue *json_get(const JsonValue *obj, const char *key);
/* Array index; returns NULL if out of range. */
JsonValue *json_at(const JsonValue *arr, int i);
/* Convenience: nested get, e.g. json_path(v, "assets", 0-ish) not supported; use chain. */
const char *json_str(const JsonValue *obj, const char *key); /* NULL if absent */
#endif