{"id":18416893,"url":"https://github.com/syntifi/borshj","last_synced_at":"2026-02-03T13:06:47.334Z","repository":{"id":43411965,"uuid":"463134006","full_name":"syntifi/borshj","owner":"syntifi","description":"Borsh binary serialization format support for Java.","archived":false,"fork":false,"pushed_at":"2022-03-03T16:58:08.000Z","size":594,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-02T15:50:22.207Z","etag":null,"topics":["borsh","near-protocol","serialization-libraries"],"latest_commit_sha":null,"homepage":"https://syntifi.github.io/borshj/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syntifi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null}},"created_at":"2022-02-24T12:08:40.000Z","updated_at":"2025-06-18T07:48:32.000Z","dependencies_parsed_at":"2022-08-26T21:40:52.486Z","dependency_job_id":null,"html_url":"https://github.com/syntifi/borshj","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/syntifi/borshj","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntifi%2Fborshj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntifi%2Fborshj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntifi%2Fborshj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntifi%2Fborshj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syntifi","download_url":"https://codeload.github.com/syntifi/borshj/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syntifi%2Fborshj/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29046503,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-03T10:09:22.136Z","status":"ssl_error","status_checked_at":"2026-02-03T10:09:16.814Z","response_time":96,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["borsh","near-protocol","serialization-libraries"],"created_at":"2024-11-06T04:07:39.175Z","updated_at":"2026-02-03T13:06:47.204Z","avatar_url":"https://github.com/syntifi.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BorshJ \n\n[![Java CI with Gradle](https://github.com/syntifi/borshj/actions/workflows/gradle.yml/badge.svg)](https://github.com/syntifi/borshj/actions/workflows/gradle.yml)\n![GitHub tag (latest SemVer)](https://img.shields.io/github/v/tag/syntifi/borshj?sort=semver)\n[![Project license](https://img.shields.io/badge/license-Apache%202-blue)](https://www.apache.org/licenses/LICENSE-2.0.txt)\n\n**BorshJ** is an implementation of the [Borsh] binary serialization format for\nJava (and Kotlin, Scala, Clojure, Groovy, Jython, JRuby, etc.) projects.\n\nBorsh stands for _Binary Object Representation Serializer for Hashing_. It is\nmeant to be used in security-critical projects as it prioritizes consistency,\nsafety, speed, and comes with a strict specification.\n\n## Features\n\n- Implements [`BorshBuffer`] on top of Java's [`ByteBuffer`].\n\n- Implements [`BorshReader`] on top of any Java [`InputStream`].\n\n- Implements [`BorshWriter`] on top of any Java [`OutputStream`].\n\n- Provides [`BorshField`] with order parameter for including and sorting POJO fields.\n\n- Provides [`BorshSubTypes`] and [`BorshSubType`] for supporting serialization of interface implementations.\n\n- Based on Java NIO, enabling high-performance, zero-copy interoperability\n  with native code via JNI.\n\n- GC friendly: avoids unnecessary copying wherever possible.\n\n## Prerequisites\n\n- [Java] 8+ (this library is compatible with Android)\n\n- [Gradle] (when building from source code)\n\n## Installation\n\nWe are working on building release binaries. They will be available here soon.\n\nIn the meantime, if you wish to try out BorshJ, you will need to build the JAR\nfile from source code yourself:\n\n```bash\ngit clone https://github.com/syntifi/borshj.git\n\ncd borshj\n\ngradle jar\n\nls -l build/libs/borshj-$(cat VERSION).jar\n```\n\n## Usage\n\nTo use the Borsh object serializer/deserializer, you need add just one import:\n\n```java\nimport com.syntifi.near.borshj.Borsh;\n```\n\n## Examples\n\nThe following code examples further below are all predicated on this simple\ndata class definition:\n\n```java\npublic class Point2D implements Borsh {\n  @BorshField(order = 1)  \n  public float x;\n  \n  @BorshField(order = 2)\n  public float y;\n\n  public Point2D() {}\n\n  public Point2D(float x, float y) {\n    this.x = x;\n    this.y = y;\n  }\n}\n```\n\n\u003e **NOTE:** Only non-transient and annotated fields with [`BorshField`] will be serialized. \n\n### Serializing an object\n\nTo serialize a [POJO], use the `Borsh.serialize()` method:\n\n```java\nPoint2D point = new Point2D(123.0, 456.0);\n\nbyte[] bytes = Borsh.serialize(point);\n```\n\n### Deserializing an object\n\nTo deserialize a [POJO], use the `Borsh.deserialize()` method:\n\n```java\nPoint2D point = Borsh.deserialize(bytes, Point2D.class);\n```\n\n## Type Mappings\n\n| Borsh                 | Java           | TypeScript  |\n|-----------------------|----------------|-------------|\n | `u8` integer          | `byte`         | `number`    |\n | `u16` integer         | `short`        | `number`    |\n | `u32` integer         | `int`          | `number`    |\n | `u64` integer         | `long`         | `BN`        |\n | `u128` integer        | [`BigInteger`] | `BN`        |\n | `f32` float           | `float`        | N/A         |\n | `f64` float           | `double`       | N/A         |\n | fixed-size byte array | `byte[]`       | `Uint8Array` |\n | UTF-8 string          | `String`       | `string`    |\n | option                | [`Optional`]   | `null` or type |\n | map                   | [`Map`]        | N/A         |\n | set                   | [`Set`]        | N/A         |\n | structs               | `Object`       | `any`       |\n| enum                  | `Enum`         | -           |\n| subtypes              | `interface`    | -           |\n\n## Frequently Asked Questions\n\n### Q: Why does my class need a default constructor?\n\nClasses used with `Borsh.deserialize()` must have a nullary default constructor\nbecause instances of the class will be instantiated through Java's\n[reflection API](https://www.baeldung.com/java-reflection).\n\n[Borsh]:           https://borsh.io\n[Gradle]:          https://gradle.org\n[Java]:            https://java.com\n[POJO]:            https://en.wikipedia.org/wiki/Plain_old_Java_object\n\n[`BigInteger`]:    https://docs.oracle.com/javase/10/docs/api/java/math/BigInteger.html\n[`BorshBuffer`]:   https://github.com/syntifi/borshj/blob/master/src/main/java/com/syntifi/near/borshj/BorshBuffer.java\n[`BorshReader`]:   https://github.com/syntifi/borshj/blob/master/src/main/java/com/syntifi/near/borshj/BorshReader.java\n[`BorshWriter`]:   https://github.com/syntifi/borshj/blob/master/src/main/java/com/syntifi/near/borshj/BorshWriter.java\n[`BorshField`]:    https://github.com/syntifi/borshj/blob/master/src/main/java/com/syntifi/near/borshj/annotation/BorshField.java\n[`BorshSubTypes`]: https://github.com/syntifi/borshj/blob/master/src/main/java/com/syntifi/near/borshj/annotation/BorshSubTypes.java\n[`BorshSubType`]:  https://github.com/syntifi/borshj/blob/master/src/main/java/com/syntifi/near/borshj/annotation/BorshSubType.java\n[`ByteBuffer`]:    https://docs.oracle.com/javase/10/docs/api/java/nio/ByteBuffer.html\n[`InputStream`]:   https://docs.oracle.com/javase/10/docs/api/java/io/InputStream.html\n[`Map`]:           https://docs.oracle.com/javase/10/docs/api/java/util/Map.html\n[`Optional`]:      https://docs.oracle.com/javase/10/docs/api/java/util/Optional.html\n[`OutputStream`]:  https://docs.oracle.com/javase/10/docs/api/java/io/OutputStream.html\n[`Set`]:           https://docs.oracle.com/javase/10/docs/api/java/util/Set.html","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntifi%2Fborshj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyntifi%2Fborshj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyntifi%2Fborshj/lists"}