{"id":19552459,"url":"https://github.com/pixeldroid/json-ls","last_synced_at":"2025-09-06T17:36:06.275Z","repository":{"id":26926791,"uuid":"30389012","full_name":"pixeldroid/json-ls","owner":"pixeldroid","description":"JSON helpers for Loom","archived":false,"fork":false,"pushed_at":"2017-09-19T02:47:18.000Z","size":36,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-26T07:18:57.036Z","etag":null,"topics":["json","json-helper","library","loomlib","loomscript","pretty-print","yaml"],"latest_commit_sha":null,"homepage":null,"language":"LoomScript","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/pixeldroid.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}},"created_at":"2015-02-06T01:44:04.000Z","updated_at":"2024-10-08T00:40:25.000Z","dependencies_parsed_at":"2022-09-02T02:40:23.922Z","dependency_job_id":null,"html_url":"https://github.com/pixeldroid/json-ls","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/pixeldroid/json-ls","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixeldroid%2Fjson-ls","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixeldroid%2Fjson-ls/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixeldroid%2Fjson-ls/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixeldroid%2Fjson-ls/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pixeldroid","download_url":"https://codeload.github.com/pixeldroid/json-ls/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixeldroid%2Fjson-ls/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273936536,"owners_count":25194194,"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","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"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":["json","json-helper","library","loomlib","loomscript","pretty-print","yaml"],"created_at":"2024-11-11T04:18:15.149Z","updated_at":"2025-09-06T17:36:06.227Z","avatar_url":"https://github.com/pixeldroid.png","language":"LoomScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"json-ls\n=======\n\nJSON helpers for Loom\n\n- [rationale](#rationale)\n- [installation](#installation)\n- [usage](#usage)\n- [building](#building)\n- [contributing](#contributing)\n\n\n## rationale\n\nLoom provides the [JSON][loom-json] class, which provides strongly typed access to values, requiring  separate accessors for every data type, and two families of these accessors for retrieving from Objects or Arrays. There are 18 basic accessors, and 2 methods for determining type.\n\nThe `Json` class in this library aims to simplify access to json data, using the `Json` class itself as the single container type, which exposes only 3 basic accessors, and 1 more for type retrieval:\n\n- `keys` - a Dictionary of Json instances, indexed by Strings\n- `items` - an Array of Json instances\n- `value` - the actual data for the instance\n- `type` - any basic System type, or Json\n  * `Null`, `Boolean`, `Number`, `String`, `Vector`, `Dictionary`, `Json`\n\nFor comparison, the code snippets below present two ways to retrieve the second value of the nested array indexed by `r` in the following json data:\n\n```json\n{\n   \"key\": [\n      {\"a\":1.23, \"b\":45.67},\n      {\"x\":8, \"y\":9},\n      {\"q\":[1,2], \"r\":[3,4], \"n\":null}\n   ],\n}\n```\n\n\u003e `json.json`\n\n#### Using `system.JSON`\n\n```ls\nvar jsonString:String = File.loadTextFile('assets/json.json');\nvar j:JSON = JSON.parse(jsonString);\ntrace(j.getArray('key').getArrayObject(2).getArray('r').getArrayNumber(1));\n```\n\n#### Using `pixeldroid.json.Json`\n\n```ls\nvar jsonString:String = File.loadTextFile('assets/json.json');\nvar j:Json = Json.fromString(jsonString);\ntrace(j.keys['key'].items[2].keys['r'].items[1]);\n```\n\n\n### JsonPrinter\n\nThis library includes a configurable JSON pretty-printer, with three pre-defined configurations for convenience.\n\nOther custom configurations are possible by adjusting the values of `JsonPrinterOptions`.\n\n#### Standard\n\nSimilar to [jsonlint][jsonlint]:\n\n```json\n{\n    \"array\": [\n        1,\n        [\n            23,\n            45\n        ],\n        [\n            67,\n            [\n                666\n            ],\n            [\n                777\n            ],\n            89\n        ]\n    ],\n    \"bool\": true,\n    \"dictionary\": {\n        \"a\": [\n            65,\n            97\n        ],\n        \"z\": {\n            \"A\": 65,\n            \"a\": 97\n        }\n    },\n    \"nulls\": \"loom dictionaries delete null values\",\n    \"number\": 987.6543,\n    \"string\": \"aA bB cC\"\n}\n```\n\n#### Compact\n\nA tighter formatting that retains readability:\n\n```json\n{\n  \"array\": [\n    1,\n    [ 23, 45 ],\n    [ 67, [ 666 ], [ 777 ], 89 ]\n  ],\n  \"bool\": true,\n  \"dictionary\": {\n    \"a\": [ 65, 97 ],\n    \"z\": { \"A\": 65, \"a\": 97 }\n  },\n  \"nulls\": \"loom dictionaries delete null values\",\n  \"number\": 987.6543,\n  \"string\": \"aA bB cC\"\n}\n```\n\n#### Minified\n\nNo extra whitespace:\n\n```json\n{\"array\":[1,[23,45],[67,[666],[777],89]],\"bool\":true,\"dictionary\":{\"a\":[65,97],\"z\":{\"A\":65,\"a\":97}},\"nulls\":\"loom dictionaries delete null values\",\"number\":987.6543,\"string\":\"aA bB cC\"}\n```\n\n\n### YamlPrinter\n\nThis library includes a configurable YAML pretty-printer, with two pre-defined configurations for convenience:\n\nOther custom configurations are possible by adjusting the values of `YamlPrinterOptions`.\n\n#### Standard\n\nAs you would find from [yamllint][yamllint]:\n\n```yaml\n---\narray:\n  - 1\n  -\n    - 23\n    - 45\n  -\n    - 67\n    -\n      - 666\n    -\n      - 777\n    - 89\nbool: true\ndictionary:\n  a:\n    - 65\n    - 97\n  z:\n    A: 65\n    a: 97\nnulls: \"loom dictionaries delete null values\"\nnumber: 987.6543\nstring: \"aA bB cC\"\n```\n\n#### Compact\n\nA tighter formatting similar to [yaml.org][yaml.org]:\n\n```yaml\n---\narray:\n  - 1\n  - [ 23, 45 ]\n  - [ 67, [ 666 ], [ 777 ], 89 ]\nbool: true\ndictionary:\n  a: [ 65, 97 ]\n  z: { A: 65, a: 97 }\nnulls: \"loom dictionaries delete null values\"\nnumber: 987.6543\nstring: \"aA bB cC\"\n```\n\n#### Custom\n\nCustom formatting can be achieved by configuring the `YamlPrinterOptions` parameter:\n\n```yaml\n---\narray:\n    - 1\n    - - 23\n      - 45\n    - - 67\n      - - 666\n      - - 777\n      - 89\nbool: true\ndictionary:\n    a:\n        - 65\n        - 97\n    z:\n        A: 65\n        a: 97\nnulls: \"loom dictionaries delete null values\"\nnumber: 987.6543\nstring: \"aA bB cC\"\n...\n```\n\n### JsonDemo\n\nsee an example of using Json here:\n\n* [JsonDemoCLI.build][JsonDemoCLI.build]\n* [JsonDemoCLI.ls][JsonDemoCLI.ls]\n\nyou can compile and run the demo from the command line:\n\n    $ rake cli\n\n\n## installation\n\nDownload the library into its matching sdk folder:\n\n    $ curl -L -o ~/.loom/sdks/sprint34/libs/Json.loomlib \\\n        https://github.com/pixeldroid/json-ls/releases/download/v1.0.0/Json-sprint34.loomlib\n\nTo uninstall, simply delete the file:\n\n    $ rm ~/.loom/sdks/sprint34/libs/Json.loomlib\n\n\n## usage\n\n0. declare a reference to the Json loomlib in your `.build` file:\n    *\n    ```json\n    \"references\": [\n        \"System\",\n        \"Json\"\n    ],\n    ```\n0. import `pixeldroid.json.Json`\n0. instantiate a new `pixeldroid.json.Json` and call the `fromString()` or `fromObject()` method on it\n0. retrieve values for key / item chains as desired\n0. print to formatted JSON string with JsonPrinter\n\n```ls\nvar jsonString:String = File.loadTextFile('assets/json.json');\nvar j:Json = Json.fromString(jsonString);\ntrace(j.keys['key_name'].items[2].value);\n```\n\n```ls\nvar jsonObject:Dictionary.\u003cString, Object\u003e = { \"bool\": true, \"array\": [1,23], \"string\": \"one two three\" };\nvar j:Json = Json.fromObject(jsonObject);\ntrace(JsonPrinter.print(j, JsonPrinterOptions.compact));\n```\n\n\n## building\n\n\u003e first install [loomtasks][loomtasks]\n\n### compiling\n\n    $ rake lib:install\n\nthis will build the Json library and install it in the currently configured sdk\n\n### running tests\n\n    $ rake test\n\nthis will build the Json library, install it in the currently configured sdk, build the test app, and run the test app.\n\n\n## contributing\n\nPull requests are welcome!\n\n\n[JsonDemoCLI.build]: ./cli/src/JsonDemoCLI.build \"build file for the CLI demo\"\n[JsonDemoCLI.ls]: ./cli/src/JsonDemoCLI.ls \"source file for the CLI demo\"\n[jsonlint]: https://jsonlint.com/ \"jsonlint\"\n[loom-json]: http://docs.theengine.co/loom/1.1.4813/api/system/JSON.html \"Loom JSON class\"\n[loomtasks]: https://github.com/pixeldroid/loomtasks \"loomtasks\"\n[yaml.org]: http://www.yaml.org/start.html \"yaml.org\"\n[yamllint]: http://www.yamllint.com/ \"yamllint\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixeldroid%2Fjson-ls","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpixeldroid%2Fjson-ls","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixeldroid%2Fjson-ls/lists"}