HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
DaveGamble
cJSON
C2019–2025
DaveGamble / cJSON

cJSON

Ultralightweight JSON parser in ANSI C

9Distinct people
9Mentions
1Explicit recommenders
13.1KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Ultralightweight JSON parser in ANSI C

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

Did you try cJSON? Works well for me. https://github.com/DaveGamble/cJSON

alex_suzuki used a recommendation phrase. One indexed comment matches. This is a phrase match, not a verdict.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year9 dated mentions

Observed mentions: 2019-01-06 18:11:18 UTC to 2025-09-21 20:50:41 UTC.

012342019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20192020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 4 mentions; 0 submissions, 4 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments20222023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2025

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC101
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC404
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC000
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC110
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC000
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC101
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC202

What Hacker News says

9 sources
> I'm assuming your statement would be meant to apply to other common languages without s-expressions, but maybe I've misunderstood. It was meant for C specifically. Take a JSON document. Define it in C. Here's what I see on a random cJSON GitHub project: https://github.com/DaveGamble/cJSON/blob/master/README.md#ex... Now do that in JavaScript: const jsonDoc = { "name": "Awesome 4K" ... } Now make the equivalent jsonDoc in Lisp with s-expressions: (define json-doc (hash "name" "Awesome 4K" "resolutions" (list (hash "width" 1280 "height" 720) (hash "width" 1920 "height" 1080) (hash "width" 3840 "height" 2160)))) The C approach is the a
Read the rest
pproach you'd similarly take in many languages where you create the HashMap, then create the Array, then populate them. Of course, you could "cheat" in many languages by first making a string and then calling the JSON library's `parse` on the string. But, this is different than JavaScript where you can directly create the JSON document. In Lisp, you are always writing s-expressions, both for data and code. > What's something that is made significantly easier by an s-expression than by arrays/tables? An s-expression is a form of syntax. Even though it is a "list", the s-expression (list 1 2 3) is an actual list. It's not like you're taking the idea of arrays and tables and replacing it with a list. It's like you're taking the idea: // Create a List in Java var l = new ArrayList(); l.add(1); l.add(2); l.add(3); // Print the List in Java System.out.println(l); // Prints [1, 2, 3]; // Can we construct a List from the String "[1, 2, 3]"? Is there a fromString() or similar for a Java Object? And replacing it with the idea: // Create a List in Lisp (define l (list 1 2 3)) // Print the List in Lisp (println l) // Prints (list 1 2 3) // Can we construct a List from the String "(list 1 2 3)"? (eval (read "(list 1 2 3)")) What about dates? What if we want rationals? What if we want to use a binary-search-tree-map instead of a hash? // Create a Date in JavaScript const date = new Date() // Print the Date in JavaScript console.log(date); // Prints Wed Apr 16 2025 00:00:00 GMT ... // Can I JSON.parse that string and receive a date? Lisp: // Create a Date in Lisp (define d (today)) // Print the Date in Lisp (println d) // Prints (date 2025 4 16) // Construct a Date from the String "(date 2025 4 16)" (eval (read "(date 2025 4 16)")) The Lisp examples are simplified, but that is the idea. > To make s-expressions language-agnostic, wouldn't you need libraries in the languages to convert between the s-expression as it exists in some specification, and the language's native data structures? Yes. > This doesn't sound all that different from JSON at this point, or a much more complex specification that defines the representation of all kinds of types, like dates. Correct. It would just be like JSON and whatever bits are standardized are what would be handled.
In Why Fennel?
My statement: https://github.com/DaveGamble/cJSON/commit/65541b900c740e1d5... At some point I have realised, that just letting cJSON be the horror of a codebase it was before I started maintaining it would have been the best thing to do, but that's what you call hindsight. At least now I know. One reason I burned out was because I felt horrified by how many people are using cJSON and felt a responsibility to make it better and safer for all of them, even though I myself haven't ever been really using it. The combination of this mounting pressure plus the the impossible fight against semantic versioning and memory unsafety gave me the rest. By improving it, but being unable to completely "fix" it, I probably led more people to use it, making the situation even worse than it was before.
In “To be safe allocate 5 bytes more than you need”
I abhor comments like these. It says that it needs to allocate 5 more bytes, and I can see that in the code, but it doesn't say why the magic number is 5. The comment explains the what but not the why. The commit message is equally as useless: https://github.com/DaveGamble/cJSON/commit/65541b900c740e1d5... What needs to be fixed so that this "+5" can be removed? What happens if something changes and the magic number needs to be 6? Also, where's the unit test?
In “To be safe allocate 5 bytes more than you need”
Because C has no package system and it sucks, and having a single file (ideally with no dependencies, which isn't the case here) makes it super easy to integrate it anywhere. A good example of that IMO is cJSON[1], it's a small self-contained single file implementation of a JSON reader and parser. It's easy to use, the code is pretty clean and easy to follow and I never ran into any obvious limitation. I very much recommend it. There are also projects that are developed as multiple files but amalgamated into a single huge file before release. SQLite does that: https://sqlite.org/amalgamation.html > Over 100 separate source files are concatenated into a single large files of C-code named "sqlite3.c" and called "the amalgamation". The amalgamation contains everything an application needs to embed SQLite. The amalgamation file is more than 2
Read the rest
20,000 lines long and over 7.5 megabytes in size (as of 2018-11-24). > Combining all the code for SQLite into one big file makes SQLite easier to deploy — there is just one file to keep track of. And because all code is in a single translation unit, compilers can do better inter-procedure optimization resulting in machine code that is between 5% and 10% faster. [1] https://github.com/DaveGamble/cJSON
In Single C file TLS 1.2/1.3 implementation using tomcrypt

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.