{"id":17998714,"url":"https://github.com/zer0-one/libtmj","last_synced_at":"2026-03-27T04:53:45.479Z","repository":{"id":65100393,"uuid":"250743375","full_name":"Zer0-One/libtmj","owner":"Zer0-One","description":"A C library for loading Tiled maps and tilesets in JSON format","archived":false,"fork":false,"pushed_at":"2024-03-13T02:50:42.000Z","size":221,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-21T06:41:41.260Z","etag":null,"topics":["tiled","tiled-map-editor","tiled-maps","tiled-parser","tiledmap"],"latest_commit_sha":null,"homepage":"https://zer0-one.github.io/libtmj/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zer0-One.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":"2020-03-28T08:04:36.000Z","updated_at":"2024-12-19T16:15:40.000Z","dependencies_parsed_at":"2024-10-29T21:54:36.888Z","dependency_job_id":null,"html_url":"https://github.com/Zer0-One/libtmj","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/Zer0-One%2Flibtmj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zer0-One%2Flibtmj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zer0-One%2Flibtmj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zer0-One%2Flibtmj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zer0-One","download_url":"https://codeload.github.com/Zer0-One/libtmj/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245597193,"owners_count":20641859,"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":["tiled","tiled-map-editor","tiled-maps","tiled-parser","tiledmap"],"created_at":"2024-10-29T21:28:27.563Z","updated_at":"2026-03-27T04:53:40.447Z","avatar_url":"https://github.com/Zer0-One.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# libtmj\n\nA library for loading [Tiled](https://www.mapeditor.org) maps in JSON format\n\nBear in mind that this library is relatively new. If you find bugs, or find\nthat the library is missing an important feature, please file an issue.\n\n## Dependencies\n\n- [`jansson`](https://github.com/akheron/jansson/)\n- [`zlib`](http://zlib.net/) (Optional, for zlib and gzip decompression support)\n- [`zstd`](https://github.com/facebook/zstd) (Optional, for zstd decompression support)\n- [`Doxygen`](https://www.doxygen.nl/) (Optional, for building documentation)\n    - [`Graphviz`](https://graphviz.org/) (Optional, for drawing graphs in the generated docs)\n\n\nTo build in Windows, use vcpkg to fetch and install the above dependencies:\n```\nvcpkg install jansson:x64-windows zstd:x64-windows zlib:x64-windows\n```\n\n## Building\n\nFrom the repository root, run:\n```\ncmake -DCMAKE_BUILD_TYPE=Release -DLIBTMJ_ZSTD=ON -DLIBTMJ_ZLIB=ON . \u0026\u0026 make\n```\n\nFor Windows users, make sure to include the vcpkg toolchain file:\n```\ncmake -DCMAKE_BUILD_TYPE=Release -DLIBTMJ_ZSTD=ON -DLIBTMJ_ZLIB=ON -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake .\ncmake --build . --config Release\n```\n\nAvailable cmake build options:\n\nOption              | Description\n------------------- | -----------\nBUILD\\_SHARED\\_LIBS | Builds a shared library instead of a static library.\nCMAKE\\_BUILD\\_TYPE  | One of \"Release\" (optimization) or \"Debug\" (runtime sanitizers + debug symbols)\nLIBTMJ\\_DOCS        | Also build documentation.\nLIBTMJ\\_ZSTD        | Build zstd decompression routines.\nLIBTMJ\\_ZLIB        | Build zlib and gzip decompression routines.\nLIBTMJ\\_TEST        | Build the test suite.\n\n## Testing\n\nIf you're going to build and run tests, don't forget to pull the Unity submodule:\n```\ngit submodule update --init\n```\n\nTo enable the test suite, invoke cmake with:\n```\n-DCMAKE_BUILD_TYPE=Debug -DLIBTMJ_TEST=True\n```\nThen run the tests with:\n```\nctest // For *nix\nctest -C Debug // For Windows\n```\n\n## Usage example\n\nBelow is a brief example of how to use libtmj. For more detail, see the [API\ndocumentation](https://zer0-one.github.io/libtmj/). Specifically, refer to the\n[Data Structures](https://zer0-one.github.io/libtmj/annotated.html) page for a\nlist of fields provided by each structure. They match the names given in the\nTiled documentation, with the exception of added fields which give the number\nof elements in array fields, whose names are `{field}_count` (as shown below\nfor the \"layer\" field).\n\n```\n#include \u003cstdbool.h\u003e\n#include \u003cstdio.h\u003e\n#include \u003cunistd.h\u003e\n\n#include \u003ctmj.h\u003e\n\n// Logging callback\nvoid log_cb(tmj_log_priority priority, const char* msg){\n    switch(priority){\n        case TMJ_LOG_DEBUG:\n            printf(\"DEBUG: %s\\n\", msg);\n            break;\n        case TMJ_LOG_INFO:\n            printf(\"INFO: %s\\n\", msg);\n            break;\n        case TMJ_LOG_WARNING:\n            printf(\"WARNING: %s\\n\", msg);\n            break;\n        case TMJ_LOG_ERR:\n            printf(\"ERR: %s\\n\", msg);\n            break;\n        case TMJ_LOG_CRIT:\n            printf(\"CRIT: %s\\n\", msg);\n            break;\n    }\n}\n\n// Layers are organized into a tree, so descend recursively\nvoid enumerate_layers(Layer* layers, size_t count){\n    for(size_t i = 0; i \u003c count; i++){\n        printf(\"Layer %d: %s\\n\", layers[i].id, layers[i].name);\n\n        if(layers[i].layers){\n            enumerate_layers(layers[i].layers, layers[i].layer_count);\n        }\n    }\n}\n\nint main(){\n    // Register logging callback\n    tmj_log_regcb(true, log_cb);\n\n    Map* map = tmj_map_loadf(\"overworld.tmj\", false);\n\n    if(!map){\n        _exit(-1);\n    }\n\n    // Print the map width and height\n    printf(\"This map is %d tiles high and %d tiles wide\\n\", map-\u003eheight, map-\u003ewidth);\n\n    // Print the names of all layers in the map\n    enumerate_layers(map-\u003elayers, map-\u003elayer_count);\n\n    // Free the map\n    tmj_map_free(map);\n}\n```\n\n## Notes\n\nJSON only defines a single number type, meant to accomodate both floating point\nvalues and integers of arbitrary length. This library truncates all input\nintegers to the size of `int` on your platform, and all input floating point\nnumbers to the size of `double` on your platform. My estimation is that this is\nacceptable for a Tiled map. If you find a case in which this breaks your map,\nplease let me know.\n\n## License\n\n    BSD 2-Clause License\n\n    Copyright (c) 2023-2024, David Zero\n    All rights reserved.\n\n    Redistribution and use in source and binary forms, with or without\n    modification, are permitted provided that the following conditions are met:\n\n    1. Redistributions of source code must retain the above copyright notice, this\n       list of conditions and the following disclaimer.\n\n    2. Redistributions in binary form must reproduce the above copyright notice,\n       this list of conditions and the following disclaimer in the documentation\n       and/or other materials provided with the distribution.\n\n    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE\n    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\n    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\n    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzer0-one%2Flibtmj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzer0-one%2Flibtmj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzer0-one%2Flibtmj/lists"}