Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
live-coding-fr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
twitch
live-coding-fr
Commits
49176d36
Commit
49176d36
authored
4 years ago
by
Colin DAMON
Browse files
Options
Downloads
Patches
Plain Diff
Json configuration and tooling
parent
393f1f76
No related branches found
No related tags found
1 merge request
!22
Resolve "Borestop"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
borestop/src/main/resources/config/application.yml
+6
-0
6 additions, 0 deletions
borestop/src/main/resources/config/application.yml
borestop/src/test/java/com/ippon/borestop/infrastructure/primay/TestJson.java
+42
-0
42 additions, 0 deletions
...va/com/ippon/borestop/infrastructure/primay/TestJson.java
with
48 additions
and
0 deletions
borestop/src/main/resources/config/application.yml
+
6
−
0
View file @
49176d36
...
...
@@ -60,6 +60,12 @@ management:
spring
:
application
:
name
:
borestop
jackson
:
default-property-inclusion
:
non_empty
serialization
:
write-dates-as-timestamps
:
false
deserialization
:
fail-on-unknown-properties
:
false
profiles
:
# The commented value for `active` can be replaced with valid Spring profiles to load.
# Otherwise, it will be filled in by maven when building the JAR file
...
...
This diff is collapsed.
Click to expand it.
borestop/src/test/java/com/ippon/borestop/infrastructure/primay/TestJson.java
0 → 100644
+
42
−
0
View file @
49176d36
package
com.ippon.borestop.infrastructure.primay
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.core.JsonProcessingException
;
import
com.fasterxml.jackson.databind.DeserializationFeature
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
com.fasterxml.jackson.datatype.jdk8.Jdk8Module
;
import
com.fasterxml.jackson.datatype.jsr310.JavaTimeModule
;
import
java.io.IOException
;
public
final
class
TestJson
{
private
static
final
ObjectMapper
jsonMapper
=
jsonMapper
();
private
TestJson
()
{}
public
static
ObjectMapper
jsonMapper
()
{
return
new
ObjectMapper
()
.
setSerializationInclusion
(
JsonInclude
.
Include
.
NON_EMPTY
)
.
registerModule
(
new
JavaTimeModule
())
.
registerModule
(
new
Jdk8Module
())
.
disable
(
DeserializationFeature
.
FAIL_ON_UNKNOWN_PROPERTIES
)
.
disable
(
DeserializationFeature
.
FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY
)
.
disable
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
);
}
public
static
<
T
>
String
writeAsString
(
T
object
)
{
try
{
return
jsonMapper
.
writeValueAsString
(
object
);
}
catch
(
JsonProcessingException
e
)
{
throw
new
AssertionError
(
"Error serializing object: "
+
e
.
getMessage
(),
e
);
}
}
public
static
<
T
>
T
readFromJson
(
String
json
,
Class
<
T
>
clazz
)
{
try
{
return
jsonMapper
.
readValue
(
json
,
clazz
);
}
catch
(
IOException
e
)
{
throw
new
AssertionError
(
"Error reading value from json: "
+
e
.
getMessage
(),
e
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment