Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSCoreManager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
VIPS
VIPSCoreManager
Commits
2044f24c
Commit
2044f24c
authored
7 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Adding custom (de)serialization
parent
fbecce4f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/nibio/vips/coremanager/config/JacksonConfig.java
+55
-0
55 additions, 0 deletions
.../java/no/nibio/vips/coremanager/config/JacksonConfig.java
with
55 additions
and
0 deletions
src/main/java/no/nibio/vips/coremanager/config/JacksonConfig.java
0 → 100644
+
55
−
0
View file @
2044f24c
/*
* Copyright (c) 2018 NIBIO <http://www.nibio.no/>.
*
* This file is part of VIPSCoreManager.
* VIPSCore is free software: you can redistribute it and/or modify
* it under the terms of the NIBIO Open Source License as published by
* NIBIO, either version 1 of the License, or (at your option) any
* later version.
*
* VIPSCoreManager is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* NIBIO Open Source License for more details.
*
* You should have received a copy of the NIBIO Open Source License
* along with VIPSCoreManager. If not, see <http://www.nibio.no/licenses/>.
*
*/
package
no.nibio.vips.coremanager.config
;
import
com.bedatadriven.jackson.datatype.jts.JtsModule
;
import
javax.ws.rs.Produces
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.ext.ContextResolver
;
import
javax.ws.rs.ext.Provider
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
import
javax.ws.rs.Consumes
;
/**
* This config ensures that Jackson serializes dates as [ISO-8601 ]-compliant notation,
* and not a timestamp. Also that JTS objects are hopefully handled correctly
* @copyright 2018 <a href="http://www.nibio.no/">NIBIO</a>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/
@Provider
@Produces
(
MediaType
.
APPLICATION_JSON
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
class
JacksonConfig
implements
ContextResolver
<
ObjectMapper
>{
private
final
ObjectMapper
objectMapper
;
public
JacksonConfig
()
{
objectMapper
=
new
ObjectMapper
();
objectMapper
.
configure
(
SerializationFeature
.
WRITE_DATES_AS_TIMESTAMPS
,
false
);
objectMapper
.
registerModule
(
new
JtsModule
());
}
@Override
public
ObjectMapper
getContext
(
Class
<?>
objectType
)
{
return
objectMapper
;
}
}
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