{"id":28028499,"url":"https://github.com/themactep/jct","last_synced_at":"2026-06-25T13:31:26.455Z","repository":{"id":291473827,"uuid":"977736109","full_name":"themactep/jct","owner":"themactep","description":"JSON configuration CLI tool","archived":false,"fork":false,"pushed_at":"2026-04-30T07:25:32.000Z","size":244,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-05-23T19:31:12.700Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/themactep.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-04T21:21:04.000Z","updated_at":"2026-05-03T15:07:12.000Z","dependencies_parsed_at":"2025-09-28T11:31:09.793Z","dependency_job_id":"22c2f2bc-66f8-4a70-a4a1-68a3a88e7619","html_url":"https://github.com/themactep/jct","commit_stats":null,"previous_names":["themactep/jct"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/themactep/jct","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themactep%2Fjct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themactep%2Fjct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themactep%2Fjct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themactep%2Fjct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/themactep","download_url":"https://codeload.github.com/themactep/jct/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/themactep%2Fjct/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34778079,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-25T02:00:05.521Z","response_time":101,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-05-11T07:16:03.145Z","updated_at":"2026-06-25T13:31:26.446Z","avatar_url":"https://github.com/themactep.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON Configuration CLI Tool\n\nA command-line tool for reading and writing JSON configuration files.\nThis tool is written in pure C with no external dependencies, making\nit suitable for cross-compilation and embedded systems.\n\n## Features\n\n- Read values from JSON configuration files using dot notation\n- Write values to JSON configuration files using dot notation\n- Import values from one JSON file into another via deep merge\n- Export differences between two JSON files (useful for OverlayFS systems)\n- Create new JSON configuration files\n- Print entire JSON configuration files\n- Restore configuration files to original state (OverlayFS support)\n- Support for nested objects and arrays\n- Support for various data types (strings, numbers, booleans, null)\n- Pretty-printing of JSON output\n\n## Building\n\n### Native Compilation\n\nTo build the project for your local machine, run:\n\n```bash\nmake\n```\n\nThis will compile the source files and create the `jct` executable.\n\n### Cross-Compilation\n\n#### Toolchain Selection\n\nThe Makefile supports multiple toolchains using the standard `CROSS_COMPILE` prefix:\n\n```bash\n# Use prefix for a toolchain found in PATH\nmake CROSS_COMPILE=mipsel-linux-gnu-\n\n# Use any custom toolchain with a full path\nmake CROSS_COMPILE=/path/to/toolchain/bin/prefix-\n```\n\nYou can also use these toolchain options with the release target:\n\n```bash\nmake CROSS_COMPILE=/path/to/toolchain/bin/mipsel-linux-musl- release\nmake CROSS_COMPILE=mipsel-linux-gnu- release\n```\n\n### Optimized Builds\n\nFor optimized builds with smaller binary size:\n\n```bash\nmake release         # Optimized build (stripped of debug info)\n```\n\nThe optimized builds use the following techniques to reduce binary size:\n- `-Os` optimization flag for size\n- Removal of unused code with `-ffunction-sections` and `-fdata-sections`\n- Stripping of debug information\n\n### Cleaning\n\nTo clean up the build artifacts:\n\n```bash\nmake clean           # Remove object files and executables\nmake distclean       # Remove all generated files (complete cleanup)\n```\n\n## Usage\n\n```\nUsage: jct [--trace-resolve] \u003cconfig_file\u003e \u003ccommand\u003e [options]\n\nCommands:\n  \u003cconfig_file\u003e get \u003ckey\u003e              Get a value from the config file\n  \u003cconfig_file\u003e set \u003ckey\u003e \u003cvalue\u003e      Set a value in the config file\n  \u003cconfig_file\u003e import \u003csource_file\u003e   Merge values from another JSON file\n  \u003cconfig_file\u003e export [\u003coriginal_file\u003e]\n                                       Export differences to stdout\n  \u003cconfig_file\u003e create                 Create a new empty config file\n  \u003cconfig_file\u003e print                  Print the entire config file\n  \u003cconfig_file\u003e restore                Restore config file to original state (OverlayFS)\n\nOptions:\n  --trace-resolve                      Trace short-name resolution steps (get/set/import/print/restore)\n\nShort-name resolution (when \u003cconfig_file\u003e has no '/' and does not end with .json):\n  Tries, in order: ./\u003cname\u003e, ./\u003cname\u003e.json, /etc/\u003cname\u003e.json (POSIX only)\n  - If none found: exit 2 with an error listing tried paths\n  - If a candidate exists but is not readable: exit 13 (do not try later candidates)\n  - Symlinks are followed; final target must be a regular file (directories are skipped)\n\nCreation rules:\n  - create requires an explicit path\n  - set may create a new file only with an explicit path\n  - import follows the same rule as set for its destination file; use an explicit path to create a new config\n  - Using a short name that does not resolve will not create; the command exits 2 with guidance\n\nExamples:\n  jct prudynt get server.host           Resolve short name 'prudynt' and read\n  jct prudynt set app.name \"My App\"     Resolve and update existing; to create, use explicit path\n  jct ./prudynt set app.name \"My App\"   Explicit path; allowed to create\n  jct config.json print                 Print the entire config file\n  jct /etc/prudynt.json export \u003e diff.json\n                                        Export differences (compares with /rom version)\n  jct modified.json export base.json \u003e diff.json\n                                        Export differences between two files\n```\n### Exit codes\n\n- 0: Success\n- 2: Not found\n  - Short name did not resolve to any candidate (get/print/restore/set)\n  - Short name used with create (and with set when it would create) — use an explicit path instead\n- 13: Permission denied\n  - A candidate file was found during short-name resolution but is not readable; later candidates are not tried\n\nNote: The restore command defines additional exit codes specific to OverlayFS operations; see the Restore section below for details.\n\n### Short-name resolution details\n\nWhen \u003cconfig_file\u003e is a short name (no path separators and no .json extension), jct searches for a JSON file deterministically:\n\n1. ./\u003cname\u003e\n2. ./\u003cname\u003e.json\n3. /etc/\u003cname\u003e.json (POSIX systems only)\n\nRules:\n- If a candidate does not exist, jct continues to the next.\n- If a candidate exists and is a directory, it is skipped.\n- If a candidate exists, symlinks are followed and the final target must be a regular file.\n- If a candidate is a regular file but not readable, jct exits immediately with code 13 (permission denied) and does not try later candidates.\n- If no candidate is selected, jct exits with code 2 (not found) and prints:\n  jct: no JSON file found for '\u003cname\u003e'; tried: ./\u003cname\u003e, ./\u003cname\u003e.json[, /etc/\u003cname\u003e.json]\n\nCreation behavior:\n- create requires an explicit path; short names are not accepted for creation and will return code 2 with guidance.\n- set may create a new file only when invoked with an explicit path; using a short name that does not resolve will return code 2 and advise supplying an explicit path (e.g., ./\u003cname\u003e.json).\n\nTip:\n- Use --trace-resolve to print the resolution steps and the final chosen path to stderr.\n\n\n### Examples\n\n#### Creating a new configuration file\n\n```bash\n./jct new_config.json create\n```\n\n#### Setting values in a configuration file\n\n```bash\n./jct config.json set server.host localhost\n./jct config.json set server.port 8080\n./jct config.json set server.ssl true\n./jct config.json set app.name \"My Application\"\n./jct config.json set app.version 1.0\n```\n\n#### Importing values from another JSON file\n\n```bash\n./jct base_config.json import overrides.json\n```\n\nThe `import` command deep-merges the source file into the destination:\n\n- Nested objects are merged recursively so you can override just a few keys\n- Arrays or non-object values from the source replace the destination value entirely\n- Any keys that exist only in the source are added to the destination\n\nThis makes it easy to check in small overlay files (for example, only `image.hflip`\nand `image.vflip`) and import them into a larger device profile in one step.\n\n#### Exporting differences between JSON files\n\n```bash\n./jct /etc/config.json export \u003e differences.json\n```\n\nThe `export` command compares two JSON files and outputs only the differences (keys and values that differ or exist only in the modified file):\n\n- When called with an absolute path (e.g., `/etc/config.json`), it defaults to comparing with `/rom/\u003cconfig_file\u003e` (for OverlayFS systems)\n- You can specify a custom original file to compare against:\n  ```bash\n  ./jct modified.json export base.json \u003e diff.json\n  ```\n- The output is a JSON object containing only the modified or added keys\n- This is useful for creating minimal overlay configurations or tracking what has changed from a baseline\n\n**Usage patterns:**\n\n```bash\n# Export differences from an OverlayFS system (compares /etc/config.json with /rom/etc/config.json)\n./jct /etc/config.json export \u003e changes.json\n\n# Export differences between any two JSON files\n./jct current.json export original.json \u003e diff.json\n\n# Use the output to create a minimal overlay file\n./jct current.json export baseline.json \u003e overlay.json\n./jct new_device.json import overlay.json\n```\n\n#### JSONPath queries (new)\n\nQuery JSON data using Goessner JSONPath.\n\nExamples:\n\n- jct books.json path \"$..author\" --mode values\n- jct books.json path \"$.store.book[?(@.price \u003c 10)].title\"\n- jct books.json path \"$.store.book[0:3]\" --mode pairs\n\nOptions:\n\n- --mode values|paths|pairs (default: values)\n- --limit N to stop after N matches\n- --strict causes parse/eval errors to exit nonzero (2 parse, 3 eval); default lenient emits [] and warns to stderr\n- --pretty pretty-prints JSON output\n- --unwrap-single when mode=values, emit the lone value instead of [value]\n\n\n#### Getting values from a configuration file\n\n```bash\n./jct config.json get server.host\n# Output: localhost\n\n./jct config.json get server.port\n# Output: 8080\n\n./jct config.json get app.name\n# Output: My Application\n```\n\n#### Printing the entire configuration file\n\n```bash\n./jct config.json print\n```\n\n#### Restoring a configuration file to its original state (OverlayFS)\n\n```bash\n./jct /etc/config.json restore\n```\n\nThis command is designed for embedded systems using OverlayFS. It:\n1. **Requires an absolute path** (must start with '/') for the config file\n2. Validates that the original file exists in `/rom/\u003cconfig_file\u003e`\n3. Checks that a modified version exists in `/overlay/\u003cconfig_file\u003e`\n4. Removes the overlay file to expose the original ROM version\n5. Remounts the overlay filesystem to apply changes\n\n**Important:** The config file path must be absolute. Relative paths are not accepted.\n\n**Examples:**\n```bash\n./jct /etc/prudynt.json restore          # ✓ Valid - absolute path\n./jct /opt/app/config.json restore       # ✓ Valid - absolute path\n./jct prudynt.json restore               # ✗ Invalid - relative path\n./jct ./config.json restore              # ✗ Invalid - relative path\n```\n\n**Exit codes:**\n- 0: Success - file restored to original state\n- 1: Original ROM file not found\n- 2: File is already original (no overlay to remove)\n- 3: Failed to remove overlay file\n- 4: Failed to remount overlay filesystem\n- 5: Invalid arguments or non-absolute path\n\n## Project Structure\n\n- `src/json_config.h` - Header file with type definitions and function declarations\n- `src/json_value.c` - Implementation of JSON value handling functions\n- `src/json_parse.c` - Implementation of JSON parsing functions\n- `src/json_serialize.c` - Implementation of JSON serialization functions\n- `src/json_config.c` - Implementation of configuration manipulation functions\n- `src/json_config_cli.c` - Main file with CLI interface\n- `Makefile` - Build configuration\n\n## License\n\nThis project is open source and available under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthemactep%2Fjct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthemactep%2Fjct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthemactep%2Fjct/lists"}