skir-java-gen
Advanced tools
+21
| MIT License | ||
| Copyright (c) 2024 Tyler Fibonacci | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
+13
-9
| { | ||
| "name": "skir-java-gen", | ||
| "version": "1.0.4", | ||
| "version": "1.0.5", | ||
| "description": "", | ||
@@ -36,22 +36,26 @@ "keywords": [], | ||
| "dependencies": { | ||
| "skir-internal": "^0.1.0", | ||
| "skir-internal": "^0.1.1", | ||
| "zod": "^4.2.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@eslint/js": "^9.39.2", | ||
| "@types/mocha": "^10.0.1", | ||
| "@eslint/js": "^10.0.1", | ||
| "@types/mocha": "^10.0.10", | ||
| "@types/node": "^20.6.0", | ||
| "@typescript-eslint/eslint-plugin": "^8.50.1", | ||
| "@typescript-eslint/parser": "^8.50.1", | ||
| "@typescript-eslint/eslint-plugin": "^8.56.0", | ||
| "@typescript-eslint/parser": "^8.56.0", | ||
| "buckwheat": "^1.1.2", | ||
| "eslint": "^9.39.2", | ||
| "eslint": "^10.0.1", | ||
| "mocha": "^11.7.5", | ||
| "prettier": "^3.2.4", | ||
| "prettier-plugin-organize-imports": "^4.2.0", | ||
| "skir": "^1.0.20", | ||
| "skir": "^1.0.25", | ||
| "ts-node": "^10.9.2", | ||
| "tsx": "^4.21.0", | ||
| "typescript": "^5.2.2", | ||
| "typescript-eslint": "^8.50.1" | ||
| "typescript-eslint": "^8.56.0" | ||
| }, | ||
| "overrides": { | ||
| "diff": "^8.0.3", | ||
| "minimatch": "^10.2.2" | ||
| } | ||
| } |
+43
-10
@@ -209,8 +209,8 @@ [](https://www.npmjs.com/package/skir-java-gen) | ||
| ```java | ||
| // Serialize 'john' to dense JSON. | ||
| final Serializer<User> serializer = User.SERIALIZER; | ||
| System.out.println(serializer.toJsonCode(john)); | ||
| // [42,"John Doe","Coffee is just a socially acceptable form of rage.",[["Dumbo",1.0,"🐘"]],[1]] | ||
| // Serialize 'john' to dense JSON. | ||
| final String johnDenseJson = serializer.toJsonCode(john); | ||
| System.out.println(johnDenseJson); | ||
| // [42,"John Doe",...] | ||
@@ -240,3 +240,4 @@ // Serialize 'john' to readable JSON. | ||
| // Serialize 'john' to binary format. | ||
| System.out.println(serializer.toBytes(john)); | ||
| final ByteString johnBytes = serializer.toBytes(john); | ||
| System.out.println(johnBytes); | ||
@@ -254,4 +255,3 @@ // The binary format is not human readable, but it is slightly more compact | ||
| final User reserializedJohn = | ||
| serializer.fromJsonCode(serializer.toJsonCode(john)); | ||
| final User reserializedJohn = serializer.fromJsonCode(johnDenseJson); | ||
| assert reserializedJohn.equals(john); | ||
@@ -265,7 +265,40 @@ | ||
| final User reserializedJane = | ||
| serializer.fromBytes(serializer.toBytes(jane)); | ||
| assert reserializedJane.equals(jane); | ||
| assert serializer.fromBytes(johnBytes).equals(john); | ||
| ``` | ||
| ### Primitive serializers | ||
| ```java | ||
| assert Serializers.bool().toJsonCode(true).equals("1"); | ||
| assert Serializers.int32().toJsonCode(3).equals("3"); | ||
| assert Serializers.int64().toJsonCode(9223372036854775807L).equals("\"9223372036854775807\""); | ||
| assert Serializers.javaHash64() | ||
| .toJsonCode(new BigInteger("18446744073709551615")) | ||
| .equals("\"18446744073709551615\""); | ||
| assert Serializers.timestamp() | ||
| .toJsonCode(Instant.ofEpochMilli(1743682787000L)) | ||
| .equals("1743682787000"); | ||
| assert Serializers.float32().toJsonCode(3.14f).equals("3.14"); | ||
| assert Serializers.float64().toJsonCode(3.14).equals("3.14"); | ||
| assert Serializers.string().toJsonCode("Foo").equals("\"Foo\""); | ||
| assert Serializers.bytes() | ||
| .toJsonCode(ByteString.of((byte) 1, (byte) 2, (byte) 3)) | ||
| .equals("\"AQID\""); | ||
| ``` | ||
| ### Composite serializers | ||
| ```java | ||
| assert Serializers.javaOptional(Serializers.string()) | ||
| .toJsonCode(java.util.Optional.of("foo")) | ||
| .equals("\"foo\""); | ||
| assert Serializers.javaOptional(Serializers.string()) | ||
| .toJsonCode(java.util.Optional.empty()) | ||
| .equals("null"); | ||
| assert Serializers.list(Serializers.bool()) // | ||
| .toJsonCode(List.of(true, false)) | ||
| .equals("[1,0]"); | ||
| ``` | ||
| ### Frozen lists and copies | ||
@@ -272,0 +305,0 @@ |
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Mixed license
LicensePackage contains multiple licenses.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
150196
1.52%18
5.88%456
7.8%1
Infinity%Updated