ASerializer3
Next-Generation Java Serialization
A powerful, human-readable serialization format that combines the simplicity of JSON with advanced type safety and extensibility. Perfect for data storage, configuration, and inter-service communication.
// Serialize any Java object
var data = Rec.of(
"name", "John Doe",
"age", 30,
"timestamp", LocalDateTime.now(),
"tags", List.of("developer", "java")
);
String serialized = ASerializer3.encode(data);
// Human-readable, type-safe output!
var restored = ASerializer3.decode(serialized);
// Perfect round-trip preservation
Why ASerializer3?
Designed for developers who demand both power and elegance
JSON Superset
Built as an extension of JSON’s grammar. ASerializer3 can read any standard JSON file while adding powerful features like comments and types.
Rich Type System
Native support for primitives, collections, dates, times, UUIDs, BigDecimal, and custom converters.
High Performance
State machine-based parser for blazing-fast encoding and decoding with minimal memory overhead.
Type Safety
Optional type annotations ensure data integrity and enable seamless polymorphic deserialization.
Extensible
Register custom converters for your own types. Seamlessly integrate with existing Java classes.
Multiple Formats
Dense, pretty-printed, or fully expanded output. Choose the format that fits your use case.
ASerializer3 vs Alternatives
| Feature | ASerializer3 | JSON | Java Serialization | XML |
|---|---|---|---|---|
| Human Readable | ✓ | ✓ | ✗ | ✓ |
| Type Preservation | ✓ | ✗ | ✓ | ~ |
| Date/Time Support | ✓ | ✗ | ✓ | ~ |
| Compact Output | ✓ | ✓ | ✗ | ✗ |
| Extensible | ✓ | ~ | ✓ | ~ |
| Comments Support | ✓ | ✗ | ✗ | ✓ |
Quick Start
Add Dependency
dependencies {
implementation 'com.amtiri:JSerializer:5.+'
}
Import and Use
import com.amtiri.tools.serializer.ASerializer3;
import com.amtiri.tools.types.Rec;
var data = Rec.of("hello", "world");
String serialized = ASerializer3.encode(data);
var restored = ASerializer3.decode(serialized);
Explore Advanced Features
// Pretty printing
String pretty = ASerializer3.encode(data,
ASerializerFormat.pretty());
// Custom converters
var serializer = new ASerializer3();
serializer.registerConverter(myConverter);
See It In Action
Java Code
var user = Rec.of(
"name", "Alice Johnson",
"email", "alice@example.com",
"age", 28,
"active", true,
"roles", List.of("admin", "editor")
);
String json = ASerializer3.encode(user);
Serialized Output
{
"name": "Alice Johnson",
"email": "alice@example.com",
"age": 28,
"active": true,
"roles": ["admin", "editor"]
}
Java Code
var data = Rec.of(
"integers", Rec.of(
"byte", (byte) 127,
"short", (short) 32000,
"long", 9000000000L,
"big_int", new BigInteger("12345678901234567890")
),
"date", LocalDate.of(2024, 2, 4),
"uuid", UUID.randomUUID(),
"bytes", "Hello".getBytes()
);
String serialized = ASerializer3.encode(data);
Serialized Output
{
bytes: (b64)"SGVsbG8=",
date: (d)"2024-02-04",
integers: {
big_int: (bi)"12345678901234567890",
byte: (i1)127,
long: (i8)"9000000000",
short: (i2)32000
},
uuid: (uuid)"a1b2c3d4-..."
}
(bd), (d), (t) annotations?
These preserve the exact Java type during deserialization, ensuring perfect round-trip conversion!
Register Custom Converter
public class ColorConverter
extends Converter3<Color, String> {
public ColorConverter() {
super("color", Color.class,
c -> String.format("#%02x%02x%02x",
c.getRed(), c.getGreen(), c.getBlue()),
s -> Color.decode(s)
);
}
}
var serializer = new ASerializer3();
serializer.registerConverter(new ColorConverter());
Use Custom Type
var theme = Rec.of(
"primary", new Color(66, 135, 245),
"secondary", new Color(245, 66, 135)
);
String serialized = serializer.enc(theme);
// Output:
// {
// primary: (color)"#4287f5",
// secondary: (color)"#f54287"
// }
Dense Format
{name:"Alice",age:28,roles:["admin","editor"]}
Minimal whitespace for storage and transmission
Pretty Format
{
age: 28,
name: "Alice",
roles: ["admin", "editor"]
}
Balanced readability with smart formatting
Expanded Format
{
age: 28,
name: "Alice",
roles: [
"admin",
"editor"
]
}
Maximum readability with full expansion
Documentation
API Reference
encode(Object)– Serialize to stringdecode(String)– Deserialize from stringencode(Object, Format)– Custom formattingregisterConverter(Converter3)– Add custom types
Supported Types
- Primitives:
int, long, float, double, boolean - Strings and enums
- Collections:
List, Set, Map - Arrays (all types)
- Date/Time:
LocalDate, LocalTime, LocalDateTime, ZonedDateTime, OffsetDateTime - Special:
UUID, BigDecimal, BigInteger, byte[]
Format Options
ASerializerFormat.dense()– Compact outputASerializerFormat.pretty()– Human-readableASerializerFormat.expanded()– Fully expandedMode.NORMAL– With type annotationsMode.JSON– Pure JSON compatibility
Advanced Features
- Comment support (
//and/* */) - Unquoted field names for simplicity
- Automatic field sorting in pretty mode
- Compression support via
ZipRec - Custom type converters
- Integration with
@Serializeannotation
Best Practices
Keep type information for perfect deserialization fidelity
Dense for APIs, Pretty for configs, Expanded for debugging
Set up custom converters during application initialization
Add inline documentation to configuration files
Perfect For
Configuration Files
Human-readable configs with comments, type safety, and validation
Data Exchange
Reliable inter-service communication with strong type preservation
Data Storage
Compact, queryable data persistence with schema evolution support
Logging & Debugging
Pretty-printed output makes inspection and troubleshooting easy
Test Fixtures
Define test data in a readable format that’s easy to maintain
API Responses
Send rich, typed data with automatic conversion and validation
Ready to Serialize Smarter?
Join developers who trust ASerializer3 for their mission-critical applications
