All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

sj.h: A Minimal C Library for JSON Parsing

By

simonpure

8mo ago· 2 min readenCode

Summary

sj.h is a minimal JSON parsing library written in C that provides a simple interface for parsing JSON strings. The library includes functions for reading JSON values, iterating through objects, and extracting data into custom structs. The example shows how to parse a JSON object containing rectangle coordinates (x, y, width, height) into a Rect struct using the library's reader and iteration functions.

Key quotes

· 5 pulled
A tiny little JSON parsing library
char *json_text = "{ \"x\": 10, \"y\": 20, \"w\": 30, \"h\": 40 }"
typedef struct { int x, y, w, h; } Rect
sj_Reader r = sj_reader(json_text, strlen(json_text))
sj_Value obj = sj_read(&r)
Snippet from the RSS feed
A tiny little JSON parsing library. Contribute to rxi/sj.h development by creating an account on GitHub.

You might also wanna read