Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
6eef7abc
Commit
6eef7abc
authored
Nov 12, 2018
by
Junling Bu
Browse files
chore[litemall-db]: 删除无用代码
parent
7cc542de
Changes
1
Hide whitespace changes
Inline
Side-by-side
litemall-db/src/main/java/org/linlinjava/litemall/db/util/JsonUtil.java
deleted
100644 → 0
View file @
7cc542de
package
org.linlinjava.litemall.db.util
;
import
java.io.OutputStream
;
import
com.fasterxml.jackson.annotation.JsonFilter
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter
;
import
com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.core.annotation.AnnotationUtils
;
public
class
JsonUtil
{
private
static
Log
log
=
LogFactory
.
getLog
(
JsonUtil
.
class
);
private
static
ObjectMapper
objectMapper
=
new
ObjectMapper
();
public
static
String
stringify
(
Object
object
)
{
try
{
return
objectMapper
.
writeValueAsString
(
object
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
public
static
String
stringify
(
Object
object
,
String
...
properties
)
{
try
{
return
objectMapper
.
writer
(
new
SimpleFilterProvider
().
addFilter
(
AnnotationUtils
.
getValue
(
AnnotationUtils
.
findAnnotation
(
object
.
getClass
(),
JsonFilter
.
class
)).
toString
(),
SimpleBeanPropertyFilter
.
filterOutAllExcept
(
properties
)))
.
writeValueAsString
(
object
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
public
static
void
stringify
(
OutputStream
out
,
Object
object
)
{
try
{
objectMapper
.
writeValue
(
out
,
object
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
}
public
static
void
stringify
(
OutputStream
out
,
Object
object
,
String
...
properties
)
{
try
{
objectMapper
.
writer
(
new
SimpleFilterProvider
().
addFilter
(
AnnotationUtils
.
getValue
(
AnnotationUtils
.
findAnnotation
(
object
.
getClass
(),
JsonFilter
.
class
)).
toString
(),
SimpleBeanPropertyFilter
.
filterOutAllExcept
(
properties
)))
.
writeValue
(
out
,
object
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
}
public
static
<
T
>
T
parse
(
String
json
,
Class
<
T
>
clazz
)
{
if
(
json
==
null
||
json
.
length
()
==
0
)
{
return
null
;
}
try
{
return
objectMapper
.
readValue
(
json
,
clazz
);
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
}
return
null
;
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
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