Skip to content

Commit

Permalink
Minor base upate
Browse files Browse the repository at this point in the history
  • Loading branch information
GedMarc committed Dec 23, 2023
1 parent c070aca commit 8559f0a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@
<artifactId>jackson-databind</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>


<dependency>
<groupId>com.guicedee.services</groupId>
<artifactId>json</artifactId>
Expand Down
1 change: 1 addition & 0 deletions src/jre11/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
requires static java.xml;

requires static org.slf4j;
requires transitive com.fasterxml.jackson.datatype.jsr310;

exports com.guicedee.guicedinjection;
exports com.guicedee.guicedinjection.interfaces;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,4 @@ public class ObjectBinderKeys
* The object reader for tiny
*/
public static final Key<ObjectReader> JavaScriptObjectReader = Key.get(ObjectReader.class, Names.named("Javascript"));

public static ObjectMapper ObjectMapperInstance;


}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.guicedee.guicedinjection.interfaces.*;
import com.guicedee.logger.*;
import jakarta.inject.*;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import static com.fasterxml.jackson.core.JsonParser.Feature.*;
import static com.guicedee.guicedinjection.interfaces.ObjectBinderKeys.*;
Expand All @@ -34,16 +35,18 @@ public class ObjectMapperBinder
@Override
public void onBind(GuiceInjectorModule module)
{
log.fine("Bound ObjectMapper (DefaultObjectMapper) as singleton [" + singleton+ "]");
log.config("Bound ObjectMapper (DefaultObjectMapper) as singleton [" + singleton+ "]");
var p = (Provider<ObjectMapper>) () -> new ObjectMapper()
.registerModule(new LaxJsonModule())
.registerModule(new JavaTimeModule())
//.registerModule(new LaxJsonModule())
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
.configure(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES, false)
.configure(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES, true)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true)
.configure(JsonGenerator.Feature.ESCAPE_NON_ASCII, true)
.enable(ALLOW_UNQUOTED_CONTROL_CHARS)
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
.setVisibility(PropertyAccessor.GETTER, JsonAutoDetect.Visibility.NONE)
.setVisibility(PropertyAccessor.IS_GETTER, JsonAutoDetect.Visibility.NONE)
Expand Down Expand Up @@ -92,7 +95,7 @@ public void onBind(GuiceInjectorModule module)

log.fine("Bound ObjectWriter.class @Named(JavaScriptObjectReader)");
module.bind(ObjectBinderKeys.JavascriptObjectMapper)
.toInstance(ObjectMapperInstance = new ObjectMapper()
.toInstance(new ObjectMapper()
.registerModule(new LaxJsonModule())
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
.configure(DeserializationFeature.FAIL_ON_MISSING_CREATOR_PROPERTIES, false)
Expand Down Expand Up @@ -140,7 +143,7 @@ public void onBind(GuiceInjectorModule module)
}

/**
* Returns the object mapper instance
* Returns the object mapper instance for JAVASCRIPT
* @return
*/
public static ObjectMapper getObjectMapper()
Expand Down

0 comments on commit 8559f0a

Please sign in to comment.