Skip to content

Commit abca337

Browse files
authored
Merge pull request #58 from SentryMan/patch-2
Adds Built in Types to README
2 parents 87fbeab + 7f66862 commit abca337

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# [Avaje-JsonB](https://avaje.io/jsonb/)
66

7-
Fast, reflection-free Json binding via apt source code generation. A source code generation style alternative to ObjectMapper, Gson (code generation vs reflection)
7+
Fast, reflection-free Json binding via apt source code generation. A light (~188kb + generated code) source code generation style alternative to Jacksons ObjectMapper, Gson (code generation vs reflection)
88

99
- Annotate java classes with `@Json` (or use `@Json.Import` for types we "don't own" or can't annotate)
1010
- `avaje-jsonb-generator` annotation processor generates java source code to convert to/from json
@@ -14,7 +14,19 @@ Fast, reflection-free Json binding via apt source code generation. A source code
1414
- Support Mixins (adding jsonb features to types we can't directly annotate).
1515
- Provides support for dynamic json views (similar in style to that presented by [LinkedIn at java one in 2009](https://www.slideshare.net/linkedin/building-consistent-restful-apis-in-a-highperformance-environment)
1616

17+
### Built-in Type Adapters
1718

19+
Built-in support for reading and writing Java’s core data types:
20+
21+
* Primitives (int, float, char...) and their boxed counterparts (Integer, Float, Character...).
22+
* BigInteger and BigDecimal
23+
* java.time classes (Instant, LocalDate, LocalDateTime...)
24+
* Arrays, Collections, Streams, Lists, Sets, and Maps
25+
* Strings
26+
* Enums
27+
* Other miscellaneous types (UUID, URL, URI)
28+
29+
1830
# Quick Start
1931

2032
## Step 1 - Add dependency
@@ -66,22 +78,28 @@ The `avaje-jsonb-generator` annotation processor will generate a JsonAdapter as
6678
for each type annotated with `@Json`. These will be automatically registered with Jsonb
6779
when it is started using a service loader mechanism.
6880

69-
For types we cannot annotate with `@Json` we can instead use `@Json.Import`.
7081
```java
7182
@Json
7283
public class Address {
7384
private String street;
7485
private String suburb;
7586
private String city;
87+
// object fields will automatically have adapters generated, no @Json required
88+
// (though you can add @Json anyway to modify the generated adapter how you wish)
89+
private OtherClass;
90+
7691
//add getters/setters
7792
}
7893
```
94+
7995
Also works with records:
8096
```java
8197
@Json
8298
public record Address(String street, String suburb, String city) { }
8399
```
84100

101+
For types we cannot annotate with `@Json` we can place `@Json.Import(TypeToimport.class)` on any class/package-info to generate the adpaters.
102+
85103
## Step 3 - Use
86104

87105
```java

0 commit comments

Comments
 (0)