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
cb52cb55
Commit
cb52cb55
authored
Mar 18, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #498 from veryangryant/json-sort-keys
* json-sort-keys: Add support for sorting json keys
parents
ca0a12ce
2e74251d
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 @
cb52cb55
...
@@ -21,11 +21,16 @@ import org.springframework.http.converter.HttpMessageConverter;
...
@@ -21,11 +21,16 @@ import org.springframework.http.converter.HttpMessageConverter;
/**
/**
* Configuration properties to configure {@link HttpMessageConverter}s.
* Configuration properties to configure {@link HttpMessageConverter}s.
*
* @author Dave Syer
* @author Piotr Maj
*/
*/
@ConfigurationProperties
(
name
=
"http.mappers"
,
ignoreUnknownFields
=
false
)
@ConfigurationProperties
(
name
=
"http.mappers"
,
ignoreUnknownFields
=
false
)
public
class
HttpMapperProperties
{
public
class
HttpMapperProperties
{
private
boolean
jsonPrettyPrint
=
false
;
private
boolean
jsonPrettyPrint
;
private
boolean
jsonSortKeys
;
public
void
setJsonPrettyPrint
(
boolean
jsonPrettyPrint
)
{
public
void
setJsonPrettyPrint
(
boolean
jsonPrettyPrint
)
{
this
.
jsonPrettyPrint
=
jsonPrettyPrint
;
this
.
jsonPrettyPrint
=
jsonPrettyPrint
;
...
@@ -35,4 +40,12 @@ public class HttpMapperProperties {
...
@@ -35,4 +40,12 @@ public class HttpMapperProperties {
return
this
.
jsonPrettyPrint
;
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 @
cb52cb55
...
@@ -38,12 +38,14 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
...
@@ -38,12 +38,14 @@ import org.springframework.http.converter.json.MappingJackson2HttpMessageConvert
import
com.fasterxml.jackson.databind.Module
;
import
com.fasterxml.jackson.databind.Module
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.SerializationFeature
;
/**
/**
* {@link EnableAutoConfiguration Auto-configuration} for {@link HttpMessageConverter}s.
* {@link EnableAutoConfiguration Auto-configuration} for {@link HttpMessageConverter}s.
*
*
* @author Dave Syer
* @author Dave Syer
* @author Christian Dupuis
* @author Christian Dupuis
* @author Piotr Maj
*/
*/
@Configuration
@Configuration
@ConditionalOnClass
(
HttpMessageConverter
.
class
)
@ConditionalOnClass
(
HttpMessageConverter
.
class
)
...
@@ -87,7 +89,12 @@ public class HttpMessageConvertersAutoConfiguration {
...
@@ -87,7 +89,12 @@ public class HttpMessageConvertersAutoConfiguration {
@ConditionalOnMissingBean
@ConditionalOnMissingBean
@Primary
@Primary
public
ObjectMapper
jacksonObjectMapper
()
{
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
@Bean
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
cb52cb55
...
@@ -64,6 +64,7 @@ server.tomcat.max-threads = 0 # number of threads in protocol handler
...
@@ -64,6 +64,7 @@ server.tomcat.max-threads = 0 # number of threads in protocol handler
# SPRING MVC (HttpMapperProperties)
# SPRING MVC (HttpMapperProperties)
http.mappers.json-pretty-print=false # pretty print JSON
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.prefix= # MVC view prefix
spring.view.suffix= # ... and suffix
spring.view.suffix= # ... and suffix
spring.resources.cache-period= # cache timeouts in headers sent to browser
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