{"id":24746766,"url":"https://github.com/xirzo/jsonlexer","last_synced_at":"2026-05-02T10:34:13.926Z","repository":{"id":274338867,"uuid":"922609927","full_name":"xirzo/JsonLexer","owner":"xirzo","description":"JSON Lexer that can be used to parse json files","archived":false,"fork":false,"pushed_at":"2025-02-25T13:09:53.000Z","size":22,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T01:28:27.923Z","etag":null,"topics":["json","lexer","parsing"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xirzo.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":"2025-01-26T17:01:20.000Z","updated_at":"2025-02-25T14:02:45.000Z","dependencies_parsed_at":"2025-01-26T18:19:36.769Z","dependency_job_id":"10bf5701-ae6d-4ca0-9137-8dc3430ba1d4","html_url":"https://github.com/xirzo/JsonLexer","commit_stats":null,"previous_names":["xirzo/jsonlexer"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/xirzo/JsonLexer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xirzo%2FJsonLexer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xirzo%2FJsonLexer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xirzo%2FJsonLexer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xirzo%2FJsonLexer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xirzo","download_url":"https://codeload.github.com/xirzo/JsonLexer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xirzo%2FJsonLexer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32531741,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"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","lexer","parsing"],"created_at":"2025-01-28T04:33:49.551Z","updated_at":"2026-05-02T10:34:13.887Z","avatar_url":"https://github.com/xirzo.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON Lexer 📄🔍\n\nThis is a simple lexer written in C that tokenizes JSON files. It breaks down JSON input into tokens, making it easier to parse and process data. 🚀\n\n---\n\n## How It Works 🛠️\n\nThe lexer reads a JSON string character by character and identifies tokens based on the JSON syntax. It uses a `Lexer` struct to keep track of the current state and a `Token` struct to represent each token.\n\n### Key Functions\n\n- `init_lexer`: Initializes the lexer with the input JSON string.\n- `next_token`: Returns the next token in the input.\n\n---\n\n## Token Types 🏷️\n\nThe lexer recognizes the following token types:\n\n| Token Type   | Example       | Description                          |\n|--------------|---------------|--------------------------------------|\n| `TOKEN_LBR`  | `{`           | Left brace                           |\n| `TOKEN_RBR`  | `}`           | Right brace                          |\n| `TOKEN_COLON`| `:`           | Colon                                |\n| `TOKEN_COMMA`| `,`           | Comma                                |\n| `TOKEN_STRING`| `\"key\"`      | String literal                       |\n| `TOKEN_NUMBER`| `123`        | Number literal                       |\n| `TOKEN_BOOLEAN`| `true`/`false` | Boolean literal                   |\n| `TOKEN_NULL` | `null`        | Null literal                         |\n| `TOKEN_EOF`  | N/A           | End of file/input                    |\n| `TOKEN_ILLEGAL`| N/A        | Illegal/unknown token                |\n\n---\n\n## Example Usage 🖥️\n\nHere’s how you can use the lexer in your code:\n\n```c\n#include \"lexer.h\"\n\nint main() {\n    const char* json = \"{\\\"key\\\": \\\"value\\\"}\";\n    struct Lexer lexer;\n    init_lexer(\u0026lexer, json);\n\n    Token token;\n\n    do {\n        token = next_token(\u0026lexer);\n        printf(\"Token: %s, Literal: %s\\n\", token_type_to_string(token.type), token.literal);\n    } while (token.type != TOKEN_EOF);\n\n    return 0;\n}\n```\n\n---\n\n## Running Tests 🧪\n\nThe project includes a suite of tests to verify the lexer's functionality. Run the tests to ensure everything works as expected:\n\n### Test Cases\n\n1. **Empty Object** `{}` ✅\n2. **Key-Number Pair** `{\"key\": 123}` ✅\n3. **Key-String Pair** `{\"key\": \"value\"}` ✅\n4. **Key-Boolean Pair** `{\"key\": true}` ✅\n5. **Key-Null Pair** `{\"key\": null}` ✅\n\n---\n\n## Project Structure 📂\n\n```\njson-lexer/\n├── lexer.h          # Lexer header file\n├── lexer.c          # Lexer implementation\n├── token.h          # Token header file\n├── token.c          # Token implementation\n├── main.c           # Main program and tests\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxirzo%2Fjsonlexer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxirzo%2Fjsonlexer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxirzo%2Fjsonlexer/lists"}