{"id":19119524,"url":"https://github.com/kale-ko/bjsl","last_synced_at":"2026-02-28T20:43:34.827Z","repository":{"id":64877155,"uuid":"576440576","full_name":"Kale-Ko/BJSL","owner":"Kale-Ko","description":"A semi-advanced Java data serialization library with features for reducing file sizes.","archived":false,"fork":false,"pushed_at":"2025-08-21T21:34:22.000Z","size":5655,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-21T21:37:39.754Z","etag":null,"topics":["data","java","java-serialization","json","parser","serialization","serializer","smile","yaml"],"latest_commit_sha":null,"homepage":"https://bjsl.kaleko.dev","language":"Java","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/Kale-Ko.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,"zenodo":null}},"created_at":"2022-12-09T21:45:39.000Z","updated_at":"2025-01-04T00:42:44.000Z","dependencies_parsed_at":"2023-10-12T10:31:15.756Z","dependency_job_id":"a73997f3-7f5b-444d-a851-4dd77a58e624","html_url":"https://github.com/Kale-Ko/BJSL","commit_stats":null,"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"purl":"pkg:github/Kale-Ko/BJSL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kale-Ko%2FBJSL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kale-Ko%2FBJSL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kale-Ko%2FBJSL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kale-Ko%2FBJSL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Kale-Ko","download_url":"https://codeload.github.com/Kale-Ko/BJSL/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Kale-Ko%2FBJSL/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29951659,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T18:42:55.706Z","status":"ssl_error","status_checked_at":"2026-02-28T18:42:48.811Z","response_time":90,"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":["data","java","java-serialization","json","parser","serialization","serializer","smile","yaml"],"created_at":"2024-11-09T05:09:52.889Z","updated_at":"2026-02-28T20:43:34.792Z","avatar_url":"https://github.com/Kale-Ko.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BJSL\n\nA semi-advanced Java data serialization library with features for reducing file sizes.\n\nBJSL is fully documented at [bjsl.kaleko.dev/docs](https://bjsl.kaleko.dev/docs/)\n\n## Parsers\n\nParsers are how you transform text or binary data in a specific format into workable object trees.\\\nThere are currently 3 supported formats.\n\n- [Json](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/parsers/JsonParser.Builder.html)\n- [Yaml](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/parsers/YamlParser.Builder.html)\n- [Smile](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/parsers/SmileParser.Builder.html) (Binary Json)\n\nThese can be accessed using [`{format}Parser.Builder`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/parsers/package-summary.html) and can be configured if needed.\n\nIt is also entirely possible to write your own parser that fits your needs.\n\n## Object Processor\n\nThe [`ObjectProcessor`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.html) is the heart of BJSL.\\\nIt takes in object trees and transforms them into standard java objects and then transforms them back into object trees.\n\n### Creation\n\nTo create an object processor construct a new [`ObjectProcessor.Builder`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.Builder.html). This will allow you to access a few options before building the processor.\n\n- [ignoreNulls](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.Builder.html#setIgnoreNulls(boolean)) -\nIgnore nulls allows you to not have null values output into the object tree when serializing maps and objects.\n\n- [ignoreArrayNulls](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.Builder.html#setIgnoreArrayNulls(boolean)) -\nIgnore array nulls allows you to not have null values output into the object tree when serializing lists and arrays.\n\n- [ignoreEmptyObjects](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.Builder.html#setIgnoreEmptyObjects(boolean)) -\nIgnore empty objects allow you to not have objects with a size of zero (maps, lists, arrays) output into the object tree.\n\n- [ignoreDefaults](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.Builder.html#setIgnoreDefaults(boolean)) -\nIgnore defaults allows you to not have default values output into the object tree.\\\nThis works by creating a new instance of the config type to read from. This requires a 0-args constructor to be present on the type.\n\n- [caseSensitiveEnums](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.Builder.html#setCaseSensitiveEnums(boolean)) -\nCase sensitive enums allows you to enable enums to be case-sensitive.\n\nWhen you are done call [`#build()`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.Builder.html#build()) and you will have your [`ObjectProcessor`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.html).\n\n### Use\n\nYou start with a [`ParsedElement`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/elements/ParsedElement.html) of some kind ([`ParsedObject`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/elements/ParsedObject.html), [`ParsedArray`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/elements/ParsedArray.html)), likely attained from a [`Parser`](#parsers), and a class you would like to deserialize it to.\n\nAn example class could be something like:\n```java\npublic class User {\n    private double foo;\n    private double bar = 17.8;\n\n    public double getFoo() {\n        return foo;\n    }\n\n    public double getBar() {\n        return bar;\n    }\n}\n```\n\nOnce you have both just call [`#toObject(element, class)`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.html#toObject(io.github.kale_ko.bjsl.elements.ParsedElement,java.lang.Class))\\\nYou are then free to modify the returned value.\\\nWhen you would like to re-serialize it call [`#toElement(object)`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.html#toElement(java.lang.Object))\n\nThe only notable limitation of the [`ObjectProcessor`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.html) is that Map keys must be translated to a [`ParsedPrimitive`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/elements/ParsedPrimitive.html) type. This can be done using [`TypeProcessor`](#type-processors)s, just output some type of [`ParsedPrimitive`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/elements/ParsedPrimitive.html). This is already done for all default types, see below.\n\n## Type Processors\n\n[`TypeProcessor`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/TypeProcessor.html)s are extensions of the [`ObjectProcessor`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.html) that allow you to serialize and deserialize any class in whatever way you see fit.\n\nAn example used in the default processors is as follows:\n```java\nTypeProcessor uuidTypeProcessor = new TypeProcessor() {\n    @Override\n    public @NotNull ParsedElement toElement(@Nullable Object object) {\n        if (object == null) {\n            return ParsedPrimitive.fromNull();\n        }\n\n        if (object instanceof UUID) {\n            return ParsedPrimitive.fromString(object.toString());\n        } else {\n            throw new InvalidParameterException(\"object must be UUID\");\n        }\n    }\n\n    @Override\n    public @Nullable Object toObject(@NotNull ParsedElement element) {\n        if (element.isPrimitive() \u0026\u0026 element.asPrimitive().isNull()) {\n            return null;\n        }\n\n        if (element.isPrimitive() \u0026\u0026 element.asPrimitive().isString()) {\n            return UUID.fromString(element.asPrimitive().asString());\n        } else {\n            throw new InvalidParameterException(\"object must be String\");\n        }\n    }\n};\n```\n\nThese are registered when building an [`ObjectProcessor`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.html) with [`#createTypeProcessor(class, typeProcessor)`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.Builder.html#createTypeProcessor(java.lang.Class,io.github.kale_ko.bjsl.processor.TypeProcessor))\n\nThere is also a list of default type processors that can be modified using [`#setDefaultTypeProcessorsOptions(options)`](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/ObjectProcessor.Builder.html#setDefaultTypeProcessorsOptions(io.github.kale_ko.bjsl.processor.DefaultTypeProcessors.Options))\\\nThis includes the following:\n- `java.util.UUID`\n- `java.net.URI`\n- `java.net.URL`\n- `java.nio.Path`\n- `java.io.File`\n- `java.net.InetAddress`\n- `java.net.InetSocketAddress`\n- `java.util.Calendar`\n- `java.util.Date`\n- `java.time.Instant`\n\nIf you think of something not on this list that you think should be feel free to open an issue.\n\n## Annotations and Conditions\n\nThere are a couple of annotation types that can be used on serialized fields.\n\n- [@AlwaysSerialize](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/annotations/AlwaysSerialize.html) - Always serialize this field, even if it is marked transient or to be excluded by ignores.\n- [@NeverSerialize](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/annotations/NeverSerialize.html) - Never serialize this field, does the same thing as marking the field as transient.\n- [@Rename](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/annotations/Rename.html) - Rename a field to this value when outputting and from this when inputting. (This does not convert old data to match, intended use is for renaming a java field and not updating data)\n\nThere are also a few values that can be used to require certain conditions on deserialized values.\n\n- [@ExpectNotNull](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/conditions/ExpectNotNull.html) - Expect that a value is never null\n- [@ExpectGreaterThan](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/conditions/ExpectGreaterThan.html) - Expect that a value is greater than (or equal to) this\n- [@ExpectLessThan](https://bjsl.kaleko.dev/docs/io/github/kale_ko/bjsl/processor/conditions/ExpectLessThan.html) - Expect that a value is less than (or equal to) this\n\n## Full example\n\n```java\nimport java.io.IOException;\nimport java.nio.file.Files;\nimport java.nio.file.Path;\nimport java.util.HashMap;\nimport java.util.Map;\nimport java.util.UUID;\n\nimport io.github.kale_ko.bjsl.elements.ParsedElement;\nimport io.github.kale_ko.bjsl.parsers.JsonParser;\nimport io.github.kale_ko.bjsl.processor.ObjectProcessor;\n\npublic class Data {\n    public static class User {\n        private double foo; // Fields can be any visibility\n        private double bar = 17.8;\n\n        public double getFoo() {\n            return foo;\n        }\n\n        public double getBar() {\n            return bar;\n        }\n    }\n\n    public Map\u003cUUID, User\u003e exampleUsers = new HashMap\u003c\u003e(); // Maps, Lists, and other Collections are supported\n\n    protected String exampleString = \"hello world!\"; // All primitive types including arrays are supported\n\n    @NeverSerialize\n    protected String excludedString = \"goodbye world :(\"; // This won't get included in the output because it is marked to never serialize\n    \n    public static void main(String[] args) throws IOException {\n        JsonParser parser = new JsonParser.Builder().build(); // Create the parser with default options\n        ObjectProcessor processor = new ObjectProcessor.Builder().build(); // Create the processor with default options\n\n        Path inputFile = Path.of(\"input.json\"); // Define input and output files\n        Path outputFile = Path.of(\"output.json\");\n\n        String inputData;\n        if (Files.exists(inputFile)) {\n            inputData = Files.readString(inputFile); // Read in the data\n        } else {\n            inputData = parser.emptyString(); // Get a parser specific empty data string (e.g. {} for json)\n        }\n\n        ParsedElement inputElement = parser.toElement(inputData); // Turn the data into an element tree\n\n        Data data = processor.toObject(inputElement, Data.class); // Turn the element tree into a Data object\n\n        // Modify data\n\n        ParsedElement outputElement = processor.toElement(data); // Turn the Data object into an element tree\n\n        String outputData = parser.toString(outputElement); // Turn the element tree into a string\n\n        Files.writeString(outputFile, outputData); // Write out the data\n    }\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkale-ko%2Fbjsl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkale-ko%2Fbjsl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkale-ko%2Fbjsl/lists"}