{"id":13780584,"url":"https://github.com/KittyGiraudel/SassyJSON","last_synced_at":"2025-05-11T13:32:39.942Z","repository":{"id":56894317,"uuid":"15866905","full_name":"KittyGiraudel/SassyJSON","owner":"KittyGiraudel","description":"[UNMAINTAINED] A Sass API for JSON.","archived":true,"fork":false,"pushed_at":"2021-03-05T13:41:06.000Z","size":292,"stargazers_count":169,"open_issues_count":5,"forks_count":23,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-06-11T17:19:49.008Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://hugogiraudel.com/SassyJSON","language":"SCSS","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/KittyGiraudel.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}},"created_at":"2014-01-13T12:00:07.000Z","updated_at":"2023-11-29T12:25:58.000Z","dependencies_parsed_at":"2022-08-20T16:00:06.283Z","dependency_job_id":null,"html_url":"https://github.com/KittyGiraudel/SassyJSON","commit_stats":null,"previous_names":["hugogiraudel/sassyjson"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KittyGiraudel%2FSassyJSON","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KittyGiraudel%2FSassyJSON/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KittyGiraudel%2FSassyJSON/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KittyGiraudel%2FSassyJSON/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KittyGiraudel","download_url":"https://codeload.github.com/KittyGiraudel/SassyJSON/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225056842,"owners_count":17414221,"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-03T18:01:17.539Z","updated_at":"2024-11-17T15:31:20.810Z","avatar_url":"https://github.com/KittyGiraudel.png","language":"SCSS","readme":"# SassyJSON [![NPM version](https://badge.fury.io/js/sassyjson.png)](http://badge.fury.io/js/sassyjson) [![Gem Version](https://badge.fury.io/rb/SassyJSON.png)](http://badge.fury.io/rb/SassyJSON)\n\n**⚠️ SassyJSON was an experimental project. It is not meant to be used in production. If you need to transit JSON data from and to your Sass layer, have a look into [Eyeglass](https://github.com/sass-eyeglass/eyeglass) and [Sassport](https://github.com/davidkpiano/sassport).**\n\nSassyJSON is a Sass-powered API for JSON. It provides you the classic `json-encode` and `json-decode` directly from your Sass files. We'll leave you the only judges of the point of this.\n\n## Install\n\nSassyJSON is available on [npm](https://npmjs.org/) or as a [Ruby Gem](http://rubygems.org/gems/SassyJSON).\n\n### Git\n\n``` git\ngit clone https://github.com/KittyGiraudel/SassyJSON.git \u0026\u0026 cd SassyJSON\n```\n\n### npm\n\n``` bash\nnpm install sassyjson --save-dev\n```\n\n### Compass extension\n\n1. `gem install SassyJSON`\n2. Add `require 'SassyJSON'` to your `config.rb`\n3. Import it in your stylesheets with `@import 'SassyJSON'`\n\n### Sass\n\nIf you only want to play around the code without cloning the repo or using npm, you can find a [single file](https://github.com/KittyGiraudel/SassyJSON/blob/master/dist/_SassyJSON.scss) containing the whole API in the [dist](https://github.com/KittyGiraudel/SassyJSON/tree/master/dist) folder.\n\nAlso, SassyJSON is available at [Sassmeister](http://sassmeister.com/).\n\n## Example\n\n### Encoding Sass to JSON\n\n#### Sass\n\n``` scss\n$map: ((a: (1 2 ( b : 1 )), b: ( #444444, false, ( a: 1, b: test ) ), c: (2 3 4 string)));\n\n@include json-encode($map);\n```\n\n#### CSS\n\n``` css\n/*! json-encode: '{\"a\": [1, 2, {\"b\": 1}], \"b\": [\"#444444\", false, {\"a\": 1, \"b\": \"test\"}], \"c\": [2, 3, 4, \"string\"]}' */\n\nbody::before {\n  display:block;\n  width:0;height:0;\n  overflow:hidden;\n  content: '{\"a\": [1, 2, {\"b\": 1}], \"b\": [\"#444444\", false, {\"a\": 1, \"b\": \"test\"}], \"c\": [2, 3, 4, \"string\"]}';\n}\n\nhead {\n  font-family: '{\"a\": [1, 2, {\"b\": 1}], \"b\": [\"#444444\", false, {\"a\": 1, \"b\": \"test\"}], \"c\": [2, 3, 4, \"string\"]}';\n}\n\n@media -json-encode {\n  json {\n    json: '{\"a\": [1, 2, {\"b\": 1}], \"b\": [\"#444444\", false, {\"a\": 1, \"b\": \"test\"}], \"c\": [2, 3, 4, \"string\"]}';\n  }\n}\n```\n\nIf you want to restrict the output to only one of the three drivers (comment, media query or regular output) you can pass a flag as the second parameter with one of the four following keywords: `all`, `comment`, `media` or `regular`. Default is `all`.\n\n### Decoding JSON to Sass\n\n``` scss\n$json-decode: json-decode('{\"a\": [1, 2, {\"b\": 1}], \"b\": [\"#444444\", false, {\"a\": 1, \"b\": \"test\"}], \"c\": [2, 3, 4, \"string\"]}');\n// (\"a\": 1 2 (\"b\": 1), \"b\": #444444 false (\"a\": 1, \"b\": \"test\"), \"c\": 2 3 4 \"string\")\n```\n\n## Importing and decoding a JSON file\n\nTo importe and decode an external `.json` file directly into a Sass variable:\n\n``` scss\n@import 'SassyJSON'; // Import SassyJSON first!\n@import 'relative/path/to/file.json?variable-name';\n// Do something with $variable-name\n```\n\n**Important:**\n\n* the path to the JSON file is relative to importing file\n* the get parameter is the variable name to use it in Sass\n\n## Requirements\n\nAll you need is a clean version of Sass 3.3. Otherwise it's just pure Sass madness.\n\n## Development\n\n### You need\n\n  * [NodeJS](http://nodejs.org)\n  * [Ruby](https://www.ruby-lang.org/)\n  * Sass 3.3 via `gem install sass --pre`\n  * `grunt-cli` via `npm install -g grunt-cli`\n\n### How to\n\n  1. Fork this repository\n  2. Run `npm install`\n  3. `grunt dev`\n  4. Make your changes + write tests\n  5. Commit + Pull request\n\n## Credits\n\n* [Fabrice Weinberg](http://twitter.com/fweinb)\n* [Kitty Giraudel](http://twitter.com/KittyGiraudel)\n","funding_links":[],"categories":["Projects","Transformations"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKittyGiraudel%2FSassyJSON","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FKittyGiraudel%2FSassyJSON","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FKittyGiraudel%2FSassyJSON/lists"}