Sorry that I'm writing not about json-c itself but this is related.
Currently it's very inconvenient to work with JSON from shell scripts.
From what I saw the most popular way is just to install jq or any other tool and call it.
The dependency is quite heavy and not installed by default on most platforms.
But it's still extremely hard to generate JSON with hierarchy.
The solution is exists in OpenWRT Linux distro that is used for routers with extremely small memory. It's called jshn and this is a command line tool that uses json-c and generates a shell script that populates json structure as hierarchy of shell variables and provides a shell script that can be included as a library to your shell script:
#!/bin/sh
# source jshn shell library
. /usr/share/libubox/jshn.sh
# generating json data
json_init
json_add_string "msg" "Hello, world!"
json_add_object "test"
json_add_int "testdata" "1"
json_close_object
MSG=`json_dump`
# MSG now contains: { "msg": "Hello, world!", "test": { "testdata": 1 } }
The tool/library is old, stable, well tested, easy to use and works perfectly.
On my working project I working a lot with scripts that runed in Ubuntu based docker containers and I have to use some Python scripts that in OpenWRT can be easily written in plain bash with the jsnh tool.
The original jshn used some OpenWRT specific code to work with map/dict (AVL tree)
I replaced it with linkhash.c from json-c and now the json-c is the only dependency to the jshn.
But in comments said that the linkhash.c is not for a public usage and may be changed without notice.
Another problem is that now I need to add this jshn package to all distros but I don't have any experience and time for this. And I'm not a C developer and can't make a good support.
If the linkhash will ever update ten you adjust changes in the jshn too to keep binary compatibility so when json-c will be updated the jshn will be updated too and users will be safe.
Also you can easily create the needed packages for other distros.
I know, this is sounds like I want to drop my work to you but I hope that this will be a good companion project fro json-c and they should be together.