{"id":18644745,"url":"https://github.com/hjson/hjson-lua","last_synced_at":"2025-04-11T12:31:11.035Z","repository":{"id":66103710,"uuid":"211170706","full_name":"hjson/hjson-lua","owner":"hjson","description":"A lightweight H/JSON library for Lua","archived":false,"fork":false,"pushed_at":"2025-03-17T13:20:20.000Z","size":73,"stargazers_count":10,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T13:46:16.732Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","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/hjson.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2019-09-26T19:55:07.000Z","updated_at":"2025-03-17T13:20:23.000Z","dependencies_parsed_at":"2024-08-29T21:29:52.134Z","dependency_job_id":"3f6e96e1-12c7-4969-80cb-5bfc9c44ec42","html_url":"https://github.com/hjson/hjson-lua","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjson%2Fhjson-lua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjson%2Fhjson-lua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjson%2Fhjson-lua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjson%2Fhjson-lua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hjson","download_url":"https://codeload.github.com/hjson/hjson-lua/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248401945,"owners_count":21097328,"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-11-07T06:13:27.321Z","updated_at":"2025-04-11T12:31:11.028Z","avatar_url":"https://github.com/hjson.png","language":"Lua","funding_links":[],"categories":["Lua"],"sub_categories":[],"readme":"# hjson-lua\nA lightweight H/JSON library for Lua\n\nPorted from [hjson-py](https://github.com/hjson/hjson-py). Inspired by rxi - [json.lua](https://github.com/rxi/json.lua).\n\n* Implemented in pure Lua: tested with Lua 5.3 and 5.4\n\n## Setup\n\n### Lua Rocks\n\n```sh\nluarocks install hjson-lua\n```\n### Manual\n\n1. drop [hjson.lua](tree/master/hjson.lua) and [hjson folder](tree/master/hjson) folder into your project\n2. require hjson.lua\n   * `hjson = require \"hjson\"`\n\n## Usage\n\nLibrary exports json.lua like and JS like api.\n\n- Lua object to HJSON - returns HJSON string\n  - `encode(obj, options)` \n  - `stringify(obj, options)`\n  - Parameters:\n    - `obj` - Lua object - `table`, `string`, `number`, `nil`, `boolean`\n    - `options` table with following values:\n      - `indent` - default `\"    \"`. Accepts string of whitespace characters or a number representing number of spaces (non indented HJSON is JSON, automatically forwards to `_to_json` version)\n      - `skip_keys` - default `true`  Skips invalid keys. If false throws error on invalid key.\n        - Valid key types: `boolean`, `nil`, `string`\n      - `sort_keys` - whether to sort keys in objects\n      - `item_sort_key` - sort function which is passed to `table.sort` sorting object keys \n      - `invalid_objects_as_type` if true functions and others objects are replaced with their type name in format `__lua_\u003ctype\u003e` e.g. `__lua_function`\n- Lua object to JSON - returns JSON string\n  - `encode(obj, options)` \n  - `stringify(obj, options)`\n  - Parameters:\n    - `obj` - Lua object - `table`, `string`, `number`, `nil`, `boolean`\n    - `options` table with following values:\n      - `indent` - default `\"    \"`. Accepts string of whitespace characters or a number representing number of spaces (non indented HJSON is JSON, automatically forwards to `_to_json` version)\n      - `skip_keys` - default `true`  Skips invalid keys. If false throws error on invalid key.\n        - Valid key types: `boolean`, `nil`, `string`\n      - `sort_keys` - whether to sort keys in objects\n      - `item_sort_key` - sort function which is passed to `table.sort` sorting object keys \n      - `invalid_objects_as_type` if true functions and others objects are replaced with their type name in format `__lua_\u003ctype\u003e` e.g. `__lua_function`\n- H/JSON to Lua object - returns Lua object\n    - `decode(str, strict, object_hook, object_pairs_hook)`\n    - `parse(str, strict, object_hook, object_pairs_hook)`\n    - Parameters:\n      - `str` has to be valid HJSON string\n      - `strict` default `true` . If true parse/decode fails on invalid control characters.\n      - `object_hook` - `function(obj)` hook which allows to adjust tables generated from JSON on per JSON object basis (including nested objects). `obj` is lua `table`.\n      - `object_pairs_hook` - `function(pairs)` hook which allows to adjust table before generation. `pairs` is table (in array form) composited from `key/value` pairs. It is called before the table for `object_hook` is generated.\n\n*`null` values contained within an array or object are converted to `nil` and are therefore lost upon decoding.*\n\n## License\nThis library is free software; you can redistribute it and/or modify it under\nthe terms of the MIT license. See [LICENSE](LICENSE) for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhjson%2Fhjson-lua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhjson%2Fhjson-lua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhjson%2Fhjson-lua/lists"}