{"id":18084763,"url":"https://github.com/coderofsalvation/json-dsl","last_synced_at":"2025-04-12T20:09:13.477Z","repository":{"id":57148867,"uuid":"45099122","full_name":"coderofsalvation/json-dsl","owner":"coderofsalvation","description":"easily create dsl's from json by evaluating json keys and values, json decode on steroids","archived":false,"fork":false,"pushed_at":"2020-05-28T19:09:20.000Z","size":5,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T20:08:54.272Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coderofsalvation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":"https://gumroad.com/l/hGYGh"}},"created_at":"2015-10-28T08:36:24.000Z","updated_at":"2024-04-17T12:49:45.000Z","dependencies_parsed_at":"2022-08-31T20:10:18.163Z","dependency_job_id":null,"html_url":"https://github.com/coderofsalvation/json-dsl","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fjson-dsl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fjson-dsl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fjson-dsl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fjson-dsl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderofsalvation","download_url":"https://codeload.github.com/coderofsalvation/json-dsl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625493,"owners_count":21135513,"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-10-31T15:08:07.038Z","updated_at":"2025-04-12T20:09:13.443Z","avatar_url":"https://github.com/coderofsalvation.png","language":"CoffeeScript","funding_links":["https://gumroad.com/l/hGYGh"],"categories":[],"sub_categories":[],"readme":"\u003cimg alt=\"\" src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/c/c9/JSON_vector_logo.svg/2000px-JSON_vector_logo.svg.png\" width=\"120px\"/\u003e\n\nGenerate your own minilanguages fast using json as a startingpoint.\nNo parsetrees, no lexical analyzers, just plain json.\n\n# Usage\n\n    $ npm install json-dsl\n\nin your code\n\n    jdsl = require('json-dsl').parse\n    output = jdsl( yourjson )\n\n# basics: xml\n\nBy default nested json is converted into xml\n\n    {\n      \"div\": {\n        \"div\": {\n          \"div\": \"foo\"\n        }\n      }\n    }\n\ngets converted into \n\n    \u003cdiv\u003e\u003cdiv\u003e\u003cdiv\u003efoo\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\n\n# customize key evaluation\n\nlets evaluate the keys in a different way:\n\n    jsondsl = require('json-dsl')\n    jsondsl.parseKey = function(k) {\n      return k + \"[%s]\";\n    };\n    output = jdsl( yourjson )\n\noutput:\n\n    div[div[div[foo]]]\n\n# customize value evaluation\n\nlets take the previous example and lets add `parseValue`\n\n    data = { foo: \"bar\" }\n    jsondsl.parseValue = function(v,data) {\n      return data[v]\n    }\n    output = jdsl( yourjson, data )\n    \noutput:\n\n    div[div[div[bar]]]\n\n# example: html template language\n\n\u003e NOTE: the dsl below is a stripped down version of the [brown](https://npmjs.org/packages/brown) template engine, a hyperminimalistic template dsl which borrows from emmet and mustache.\n\nsetup dsl:\n\n    var jdsl = require('json-dsl');\n    var zen = require('zen-coding');\n  \n    jdsl.parseKey = function(k) {\n      return zen(k + '\u003e{%s}');\n    };\n  \n    jdsl.parseValue = function(v, data) {\n      return data[v];\n    };\n\nlets test it:\n  \n    var json = {\n      'div#foo.flop\u003efieldset\u003ediv\u003eul': {\n        'li.one\u003ea[href=\"/\"]': 'one',\n        'li.two\u003ea[href=\"/\"]': 'two'\n      }\n    };\n  \n    var data = {\n      'one': 'hello',\n      'two': 'world'\n    };\n  \n    console.log(JSON.stringify(json, null, 2));\n    console.log(jdsl.parse(json, data));\n\noutputs:\n\n    \u003cdiv id=\"foo\" class=\"flop\"\u003e\u003cfieldset\u003e\u003cdiv\u003e\u003cul\u003e\u003cli class=\"one\"\u003e\u003ca href=\"/\"\u003ehello\u003c/a\u003e\u003c/li\u003e\u003cli class=\"two\"\u003e\u003ca href=\"/\"\u003eworld\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e\u003c/div\u003e\u003c/fieldset\u003e\u003c/div\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderofsalvation%2Fjson-dsl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderofsalvation%2Fjson-dsl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderofsalvation%2Fjson-dsl/lists"}