“无法识别的令牌'com':期待('true','false'或'null')”

问题描述 投票:4回答:1

我已将此json转换为字符串以保存在本地数据库中

{
        "type": "file",
        "id": "b665ff0b-5f7b-4991-ae88-ac5054880223",
        "link": {
            "href": "https://s3-eu-west-com/87e9edff-e7bd-49ea-aa7a-8948cac29bc1/b665ff0b-5f7b-4991-ae88-ac5054880223.jpg"
        },
        "file_name": "sony 431.jpg",
        "mime_type": "image/jpeg",
        "file_size": 66727,
        "public": true,
        "meta": {
            "dimensions": {
                "width": 1500,
                "height": 1500
            },
            "timestamps": {
                "created_at": "2018-01-22T11:07:35.527Z"
            }
        },
        "links": {
            "current": "https://api.e-com.com/v2/files/b665ff0b-5f7b-4991-ae88-ac5054880223"
        }
    }

当我通过转换为JSON使用该字符串时,我收到错误说

“无法识别的令牌'com':期待('true','false'或'null')”

我该如何解决该错误?

这就是我将这个json转换为字符串的方式:

staticFile1.setFile(file.toString());

和字符串到json:

File file1 = new ObjectMapper().readValue(file, File.class);
java android json string-conversion jsonexception
1个回答
1
投票

我相信你会收到这样的错误

无法识别的令牌'com':期待('true','false'或'null')\ n在[来源:(字符串)\“com.jwt.secured.user.ApplicationUser@6d9cce48:用户名:justiuser;密码: [PROTECTED];已启用:true; AccountNonExpired:true; credentialsNonExpired:true; AccountNonLocked:true;未授予任何权限\“; line:1,column:4]“,

com与字符串中的包引用相关。在类中给出一个合适的toString()实现,并使用ObjectMapper().writeValueAsString将converto转换为String。

© www.soinside.com 2019 - 2024. All rights reserved.