{"id":13587537,"url":"https://github.com/kristopolous/TickTick","last_synced_at":"2025-04-07T22:31:22.014Z","repository":{"id":1972129,"uuid":"2903419","full_name":"kristopolous/TickTick","owner":"kristopolous","description":"JSON in your Bash scripts","archived":false,"fork":false,"pushed_at":"2020-05-29T22:17:42.000Z","size":105,"stargazers_count":581,"open_issues_count":12,"forks_count":55,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-22T23:51:11.969Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://9ol.es/TheEmperorsNewClothes.html","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"assemblymade/meta","license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kristopolous.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.APACHE2","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-12-03T05:08:55.000Z","updated_at":"2025-03-10T14:29:58.000Z","dependencies_parsed_at":"2022-09-21T09:01:11.637Z","dependency_job_id":null,"html_url":"https://github.com/kristopolous/TickTick","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristopolous%2FTickTick","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristopolous%2FTickTick/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristopolous%2FTickTick/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kristopolous%2FTickTick/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kristopolous","download_url":"https://codeload.github.com/kristopolous/TickTick/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247740754,"owners_count":20988262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-08-01T15:06:15.408Z","updated_at":"2025-04-07T22:31:21.705Z","avatar_url":"https://github.com/kristopolous.png","language":"Shell","funding_links":[],"categories":["Shell","\u003ca name=\"data-management-json\"\u003e\u003c/a\u003eData management - JSON/YAML/etc."],"sub_categories":[],"readme":"# Introduction\n\nTickTick enables you to put JSON in bash scripts.  Yes, just encapsulate them with two back-ticks.\n\n**Note: This is just a fun hack.** You may want to consider using mature languages like Ruby or Perl to solve actual real life problems.  Oh who am I kidding, I use whitespace and brainfuck every day.\n\n# Usage\n\nProper usage (if there is such a thing), is to place the following line right after the \"shbang\" at the top of your script. For instance:\n\n    #!/bin/bash\n    #\n    # Nuclear_meltdown_preventer.sh\n    #\n    # This is really important stuff. Don't edit it!\n    #\n    . ticktick.sh\n\n    ..\n\nSee how that's near the tippity-top? That's where it's supposed to go. If you put it lower, all bets are off. :-(\n\n# API\n\nArrays\n---\n\nA few array manipulation runtime directives are supported:\n \n * `[]` (as new Array) \u003cpre\u003e\\`\\`arr = [\"foo\"]\\`\\`\u003c/pre\u003e\n * `[]` (to index)     \u003cpre\u003eecho \\`\\`arr[0]\\`\\`\u003c/pre\u003e\n * `length`            \u003cpre\u003earr_len=\\`\\`arr.length()\\`\\`; echo ${arr_len}\u003c/pre\u003e\n * `push`              \u003cpre\u003e\\`\\`arr.push(${arr_len})\\`\\`\u003c/pre\u003e\n * `pop`               \u003cpre\u003eecho \\`\\`arr.pop()\\`\\`\u003c/pre\u003e\n * `shift`             \u003cpre\u003eecho \\`\\`arr.shift()\\`\\`\u003c/pre\u003e\n * `delete`            \u003cpre\u003eecho \\`\\`key.value.delete()\\`\\`\u003c/pre\u003e\n * `items`             \u003cpre\u003efor x in \\`\\`arr.items()\\`\\`; do echo \"${x}\"; done\u003c/pre\u003e\n\nNotes: \n\n * These feature do not preclude having variables by those names.  You can have ``key.delete = 1`` and then ``key.delete.delete()``\n * Since TickTick is a Bash-emitting transpiler, things that don't work in bash (such as modifying [in-shell variables](https://github.com/kristopolous/TickTick/issues/5) in double quotes) don't work in TickTick.\n\nObjects\n---\n\n * `{}` (as new Object) \u003cpre\u003e\\`\\`obj = { \"foo\": \"bar\", \"baz\": \"qux\" }\\`\\`\u003c/pre\u003e\n * `[]` (to index)      \u003cpre\u003eecho \\`\\`obj[\"foo\"]\\`\\`\u003c/pre\u003e\n * `.` (to index)       \u003cpre\u003eecho \\`\\`obj.baz\\`\\`\u003c/pre\u003e\n\nMiscellaneous\n---\n\n#### tickParse - parse things inline\n * Inline parsing: You can parse a file in with the `tickParse` routine (see the example).\n\n#### tickVars - see the currently defined variables\n * Show all variables: You can see the current values defined in the TickTick world with the `tickVars` routine.\n * If you don't like the output, there are some options to customize it. Try `tickVars -h` for more information.\n\n#### tickReset - clear the currently defined variables\n * Clear all variables: You can erace any JSON you have created/imported with the `tickReset` routine.\n\n#### __tick_var_debug - See the interim bash code\n * Dry run (display compiled code): TickTick is a mini-compiler that emits bash. If you declare `export __tick_var_debug=1` at the top of your code (before you source ticktick.sh), then the code will not run but instead print what it would have run.\n\nBash variables ($) in JSON\n---\n\nAlong with assignment operations\u003csup\u003e1\u003c/sup\u003e, and Javascript like indexing into objects and arrays.\n\nAdditionally, bash variables (eg., \"$name\") are preserved in the TickTick blocks.  For instance, once could do\n\n\u003cpre\u003e\n`` Var.Data = [] ``\n`` Var.Data.push($key) ``\nbashvar=`` Var.Data.pop() ``\n\u003c/pre\u003e\n\n\u003csup\u003e1\u003c/sup\u003eAlthough Javascript supports $ prefixed variables, this does not.\n# Examples\n\nInline Parsing\n---\n\n    #!/bin/bash\n\n    . ticktick.sh\n\n    bob=Bob\n\n    ``\n      people = {\n        \"HR\" : [\n          \"Alice\",\n          $bob,\n          \"Carol\"\n        ],\n        \"Sales\": {\n          \"Gale\": { \"profits\" : 1000 },\n          \"Harry\": { \"profits\" : 500 }\n        }\n      }\n    ``\n\n    function printEmployees() {\n      echo\n      echo \"  The ``people.Engineering.length()`` Employees listed are:\"\n\n      for employee in ``people.Engineering.items()``; do\n        printf \"    - %s\\n\" \"${!employee}\"\n      done\n\n      echo \n    }\n\n    echo Base Assignment\n    `` people.Engineering = [ \"Darren\", \"Edith\", \"Frank\" ] ``\n    printEmployees\n\n    newPerson=Isaac\n    echo Pushed a new element by variable, $newPerson onto the array\n    `` people.Engineering.push($newPerson) ``\n    printEmployees\n\n    echo Shifted the first element off: `` people.Engineering.shift() ``\n    printEmployees\n\n    echo Popped the last value off: `` people.Engineering.pop() ``\n    printEmployees\n\n    echo Indexing an array, doing variable assignments\n\n    person0=``people.HR[0]``\n    echo $person0 ``people.HR[1]``\n\nUsing a File or cURL\n---\n\n    #!/bin/bash\n    . ../ticktick.sh\n\n    # File\n    DATA=`cat data.json`\n    # cURL\n    #DATA=`curl http://foobar3000.com/echo/request.json`\n\n    tickParse \"$DATA\"\n\n    echo ``pathname``\n    echo ``headers[\"user-agent\"]``\n\n## Mailing List\n\nJoin it [over here](http://groups.google.com/group/ticktick-project).\n\n## LICENSE\n\nThis software is available under the following licenses:\n\n  * MIT\n  * Apache 2\n\nParts of this work are derived from [JSON.sh](https://github.com/dominictarr/JSON.sh), which is also available under the aforementioned licenses.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristopolous%2FTickTick","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkristopolous%2FTickTick","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkristopolous%2FTickTick/lists"}