{"id":21041004,"url":"https://github.com/chfoo/llama","last_synced_at":"2025-10-01T04:30:57.215Z","repository":{"id":47461007,"uuid":"248408157","full_name":"chfoo/llama","owner":"chfoo","description":"MessagePack encoder/decoder library for Haxe","archived":false,"fork":false,"pushed_at":"2020-09-17T03:38:29.000Z","size":48,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2023-03-23T04:57:49.978Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haxe","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/chfoo.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":"2020-03-19T04:09:54.000Z","updated_at":"2022-07-20T21:48:45.000Z","dependencies_parsed_at":"2022-09-23T06:30:23.890Z","dependency_job_id":null,"html_url":"https://github.com/chfoo/llama","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chfoo%2Fllama","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chfoo%2Fllama/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chfoo%2Fllama/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chfoo%2Fllama/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chfoo","download_url":"https://codeload.github.com/chfoo/llama/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225364551,"owners_count":17462827,"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-19T13:49:45.484Z","updated_at":"2025-10-01T04:30:56.835Z","avatar_url":"https://github.com/chfoo.png","language":"Haxe","readme":"# Llama: MessagePack library for Haxe\n\nLlama is a MessagePack (MsgPack) encoder/decoder library for Haxe.\n\nLlama is intended to be a modern alternative to the [msgpack-haxe](https://github.com/aaulia/msgpack-haxe) library with better reusability.\n\n## Supported types\n\n| MsgPack type | Haxe type |\n|--------------|-----------|\n| nil | null |\n| false, true | bool |\n| uint, int | Int, Int64 |\n| float | Float |\n| bin | Bytes |\n| str | String |\n| ext | llama.Extension |\n| array | Array |\n| map | IMap (llama.AssociativeArray), anon struct |\n\n### Limits\n\n* When encoding `Int`, the library assumes it holds a 32-bit value. It will be truncated otherwise.\n* When decoding `uint 32`, the value will be promoted to `Int64` if it does not fit in `Int`.\n* When decoding `uint 64`, the value will be interpreted as `Int64`.\n* The maximum size of a map or length of an array is the upper limit of `Int` (2147483647).\n* On targets without a integer data type, numbers will be encoded as 32-bit integers wherever possible.\n\n### Supported targets\n\n| Target | Supported? |\n|--------|------------|\n| JS | Yes |\n| Lua | Yes |\n| Flash (SWF) | Yes |\n| Neko | No. 31-bit integer limitation. |\n| PHP | Yes |\n| C++ (CPP) | Yes |\n| C# (CS) | Yes* |\n| Java | Yes |\n| Python | Yes |\n| HashLink (HL) | Yes |\n\n* On C#, only maps with `IMap\u003cAny,Any\u003e`, `IMap\u003cString,Any\u003e`, `IMap\u003cInt,Any\u003e`, and anonymous structures are supported.\n\n## Getting started\n\nRequires Haxe 4.0+\n\nInstall it using haxelib:\n\n        haxelib install llama\n\nOr directly from Git repo:\n\n        haxelib git llama https://github.com/chfoo/llama.git\n\n### Simple interface\n\nTo quickly decode and encode, use the simplified interface:\n\n```haxe\nimport llama.Llama;\n\nfinal myData:Bytes = Llama.encode(\"hello world!\");\nfinal myDoc:String = Llama.decode(myData);\n```\n\n### Encoder and decoder interface\n\nThe advanced interface provides much better control on the decoding and encoding process.\n\n#### Encoding\n\nThe encoder works on a `Output` instance such as `BytesOutput` or `FileOutput`:\n\n```haxe\nfinal output = new BytesOutput();\nfinal encoder = new Encoder(output);\n\nencoder.encode(\"hello world!\");\n\nfinal myData = output.getBytes();\n```\n\nIf you have any objects that need to be serialized manually, you can provide a custom encoder callback:\n\n```haxe\nencoder.customEncoder = (encoder, object) -\u003e {\n    if (Std.is(object, MyCustomClass)) {\n        encoder.encodeString(object.toString());\n    } else {\n        throw 'Unsupported object $object';\n    }\n};\n```\n\nIf you have any extensions, the class can implement `Extension` which the encoder will use for serialization:\n\n```haxe\nclass MyCustomExtension implements Extension {\n    public function new() {}\n\n    public function extensionType():Int {\n        return 123;\n    }\n\n    public function extensionData():Bytes {\n        return Bytes.ofString(\"hello world!\");\n    }\n}\n\nencoder.encode(new MyCustomExtension());\n```\n\nIf there is any object that cannot be encoded, a `String` exception will be thrown.\n\n#### Decoding\n\nThe decoder works on a `Input` instance such as `BytesInput` or `FileInput`:\n\n```haxe\nfinal input = new BytesInput(myData);\nfinal decoder = new Decoder(input);\n\nfinal object = decoder.decode();\n```\n\nIf there is any decoding errors, a `String` exception will be thrown.\n\nBy default, `map` types are decoded to `AssociativeArray` implementing `IMap`. This class works with any type as the keys, but map operations are O(n) time which can be unsuitable for large maps. If you know the type of the map keys, you can provide a map factory to the decoder:\n\n```haxe\n// StringMap\ndecoder = new Decoder(input);\ndecoder.mapFactory = () -\u003e new Map\u003cString,Any\u003e();\n\n// IntMap\ndecoder = new Decoder(input);\ndecoder.mapFactory = () -\u003e new Map\u003cInt,Any\u003e();\n\n// anonymous structure\ndecoder = new Decoder(input);\ndecoder.mapFactory = () -\u003e {};\n```\n\nTo convert any extensions, you can provide a extension handler callback:\n\n```haxe\ndecoder.extensionDecoder = (decoder, extension) {\n    switch extension.extensionType()\n        case 123:\n            return new MyCustomType(extension.extensionData());\n        default:\n            return extension;\n    }\n};\n```\n\nWhen parsing untrusted input, the decoder will accept any size and may crash. To avoid this, set the `maxMapSize`, `maxArrayLength`, `maxBytesLength`, and `maxRecursionDepth` fields on `decoder`.\n\n### Further reading\n\nAPI docs: https://chfoo.github.io/llama/api/\n\n## Contributing\n\nIf you have any issues or fixes, please file a issue or pull request.\n\n## License\n\nSee LICENSE file.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchfoo%2Fllama","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchfoo%2Fllama","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchfoo%2Fllama/lists"}