我有一个JSON字符串,我将它作为字符串存储在数据库中。在前端,我将这个JSON渲染为对象。检查JSON是否在使用Jackson的JAVA中有效
我使用:
JSON.parse(string);
Uncaught Syntax error: Unexpected Token
字符串:
{
"id": "295cd59f-4033-438c-9bf4-c571829f134e",
"from": "Shrisha S.<[email protected]>",
"to": [
"Katie Porter <[email protected]>"
],
"cc": [
"Jack d<[email protected]>, Keerthi<[email protected]>"
],
"bcc": [
]
}
有没有什么方法可以检查如果JSON是有效还是无效的JAVA?
这里要注意的一件事是,我没有为JSON定义的模式,我可以映射到它,即JSON可以容纳任何东西。
我目前正在尝试与JACKSON
,但因为我需要一个预先定义的模式,我没有。无论如何,这可以解决吗?
通过捕捉异常,可能。查看http://stackoverflow.com/questions/10226897/how-to-validate-json-with-jackson-json – 2015-04-02 13:37:56
JavaScript确实与这个问题无关,标签被移除。 – Cerbrus 2015-04-02 13:39:18
可能重复的[试图验证json-using-jackson-through-spring-boot-rest](http://stackoverflow.com/questions/29340290/trying-to-validate-json-using-jackson-通过弹簧引导休息) – 2015-04-02 13:57:54