Skip to content

Commit 2cb6155

Browse files
committed
Backwards compatibility check and update documentation
1 parent 34ff259 commit 2cb6155

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed

accessors-smart/src/main/java/be/atbash/json/asm/mapper/FieldPropertyNameMapperHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import be.atbash.util.StringUtils;
2020

2121
import java.util.ArrayList;
22-
import java.util.Iterator;
2322
import java.util.List;
2423
import java.util.ServiceLoader;
2524

json-smart/pom.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,46 @@
5353

5454
</dependencies>
5555

56+
<build>
57+
<plugins>
58+
<plugin>
59+
<groupId>org.codehaus.mojo</groupId>
60+
<artifactId>clirr-maven-plugin</artifactId>
61+
<version>2.8</version>
62+
<configuration>
63+
<ignored>
64+
<difference>
65+
<!-- internal, no effect -->
66+
<className>**/JSONUtil$JsonSmartFieldFilter</className>
67+
<differenceType>4001</differenceType>
68+
<to>**/FieldFilter</to>
69+
</difference>
70+
<difference>
71+
<!-- internal, no effect -->
72+
<className>**/JSONUtil$JsonSmartFieldFilter</className>
73+
<differenceType>7002</differenceType>
74+
<method>*</method>
75+
</difference>
76+
<difference>
77+
<!-- internal, no effect -->
78+
<className>**/JSONUtil$JsonSmartFieldFilter</className>
79+
<differenceType>7009</differenceType>
80+
<method>*</method>
81+
</difference>
82+
<difference>
83+
<!-- internal, no effect -->
84+
<className>**/reader/BeanEncoder</className>
85+
<differenceType>6004</differenceType>
86+
<field>beansAccess</field>
87+
<from>*</from>
88+
<to>*</to>
89+
</difference>
90+
91+
</ignored>
92+
93+
</configuration>
94+
</plugin>
95+
</plugins>
96+
</build>
97+
5698
</project>

src/main/doc/manual.adoc

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ User manual for Atbash JSON.
1515
. SPI for defining JSON property name
1616
. Integrated access-smart for additional features
1717

18+
Breaking changes
19+
. Due to integration of _access-smart_, some internal classes are using now other dependent class names (to Atbash package names). But should not affect developer code which only uses @PublicAPI.
20+
1821
=== 0.9.0
1922

2023
. Initial release, based on the code of JSON smart v2.
@@ -162,6 +165,15 @@ public class PriceJSONWriter implements JSONWriter<PriceWithWriter> {
162165

163166
In this example, the Currency object implements the _JSONAware_ interface.
164167

168+
The last option discussed here, is to register the JSONWriter within the system, as follows
169+
170+
----
171+
JSONValue.registerWriter(MyColor.class, new MyColorWriter());
172+
----
173+
174+
Then the writer is picked up whenever you ask for converting the MyColor class in this example to JSON.
175+
176+
165177
=== Custom reading of JSON
166178

167179
The conversion from JSON to an object instance can be customized by encoders which can be defined with _@MappedBy_.
@@ -185,6 +197,21 @@ An implementation of this interface or the class, needs a no argument constructo
185197

186198
Both classes needs to be specified by a @MappedBy annotation, _encoder()_ member for the simple CustomJSONEncoder implementation, _beanEncoder()_ member for CustomBeanJSONEncoder class.
187199

200+
Another customization is possible by registering encoders into the system itself, and then they don't need to be defined by a _mappedBy_ annotation. (It has more flexibility but is more difficult)
201+
202+
Start by extending the ++JSONEncoder<T>++ class and register it by
203+
204+
----
205+
JSONValue.registerEncoder(<target>.class, new CustomEncoder());
206+
207+
JSONValue.registerEncoder(new TypeReference<MyType<...>>() {}, new CustomEncoder());
208+
----
209+
210+
The second statement is for registering a Typed reference. This workaround is required to compensate for the Type erasure which is performed by Java.
211+
212+
After registering, this encoder are used when you ask to _parse_ a certain String to the specified type.
213+
214+
The test classes have examples if you want to use this type of customization.
188215

189216
== @JsonIgnore
190217

src/main/doc/manual.pdf

22.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)