Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
2e74251d
Commit
2e74251d
authored
Mar 15, 2014
by
Piotr Maj
Committed by
Phillip Webb
Mar 18, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for sorting json keys
Add `jsonSortKeys` property to HttpMapperProperties. Fixes gh-498
parent
ca0a12ce
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
2 deletions
+23
-2
HttpMapperProperties.java
...ramework/boot/autoconfigure/web/HttpMapperProperties.java
+14
-1
HttpMessageConvertersAutoConfiguration.java
...configure/web/HttpMessageConvertersAutoConfiguration.java
+8
-1
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMapperProperties.java
View file @
2e74251d
...
...
@@ -21,11 +21,16 @@ import org.springframework.http.converter.HttpMessageConverter;
/**
* Configuration properties to configure {@link HttpMessageConverter}s.
*
* @author Dave Syer
* @author Piotr Maj
*/
@ConfigurationProperties
(
name
=
"http.mappers"
,
ignoreUnknownFields
=
false
)
public
class
HttpMapperProperties
{
private
boolean
jsonPrettyPrint
=
false
;
private
boolean
jsonPrettyPrint
;
private
boolean
jsonSortKeys
;
public
void
setJsonPrettyPrint
(
boolean
jsonPrettyPrint
)
{
this
.
jsonPrettyPrint
=
jsonPrettyPrint
;
...
...
@@ -35,4 +40,12 @@ public class HttpMapperProperties {
return
this
.
jsonPrettyPrint
;
}
public
void
setJsonSortKeys
(
boolean
jsonSortKeys
)
{
this
.
jsonSortKeys
=
jsonSortKeys
;
}
public
boolean
isJsonSortKeys
()
{
return
this
.
jsonSortKeys
;
}
}
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConvertersAutoConfiguration.java
View file @
2e74251d
...
...
@@ -38,12 +38,14 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
import
com.fasterxml.jackson.databind.Module
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
/**
* {@link EnableAutoConfiguration Auto-configuration} for {@link HttpMessageConverter}s.
*
* @author Dave Syer
* @author Christian Dupuis
* @author Piotr Maj
*/
@Configuration
@ConditionalOnClass
(
HttpMessageConverter
.
class
)
...
...
@@ -87,7 +89,12 @@ public class HttpMessageConvertersAutoConfiguration {
@ConditionalOnMissingBean
@Primary
public
ObjectMapper
jacksonObjectMapper
()
{
return
new
ObjectMapper
();
ObjectMapper
objectMapper
=
new
ObjectMapper
();
if
(
this
.
properties
.
isJsonSortKeys
())
{
objectMapper
.
configure
(
SerializationFeature
.
ORDER_MAP_ENTRIES_BY_KEYS
,
true
);
}
return
objectMapper
;
}
@Bean
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
2e74251d
...
...
@@ -64,6 +64,7 @@ server.tomcat.max-threads = 0 # number of threads in protocol handler
# SPRING MVC (HttpMapperProperties)
http.mappers.json-pretty-print=false # pretty print JSON
http.mappers.json-sort-keys=falose # sort keys
spring.view.prefix= # MVC view prefix
spring.view.suffix= # ... and suffix
spring.resources.cache-period= # cache timeouts in headers sent to browser
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment