“无法识别的令牌'com':正在期待('true','false'或'null')'" [英] "Unrecognized token 'com': was expecting ('true', 'false' or 'null')"

查看:112
本文介绍了“无法识别的令牌'com':正在期待('true','false'或'null')'"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have converted this json to string to save in local database

{
        "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使用该字符串时,出现错误提示

When I am using that string by converting into JSON I am getting error saying

无法识别的令牌'com':正在等待('true','false'或'null')"

"Unrecognized token 'com': was expecting ('true', 'false' or 'null')"

如何解决该错误?

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

This is how I converted this json into string:

staticFile1.setFile(file.toString());

和json字符串:

File file1 = new ObjectMapper().readValue(file, File.class);

推荐答案

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

I believe you are getting an error like this

无法识别的令牌"com":正在等待("true","false"或"null")\ n 在[来源:(String)\"com.jwt.secured.user.ApplicationUser@6d9cce48: 用户名:justiuser;密码保护];启用:true; AccountNonExpired:true; certificateNonExpired:true; AccountNonLocked:true;未授予任何权限;;第1行: 栏:4],

Unrecognized token 'com': was expecting ('true', 'false' or 'null')\n at [Source: (String)\"com.jwt.secured.user.ApplicationUser@6d9cce48: Username: justiuser; Password: [PROTECTED]; Enabled: true; AccountNonExpired: true; credentialsNonExpired: true; AccountNonLocked: true; Not granted any authorities\"; line: 1, column: 4]",

.com与字符串中的包引用相关.在类中提供适当的toString()实现,并使用ObjectMapper().writeValueAsString转换为String.

The com is related to the package reference in the string. Give a proper toString() implementation in the class and use ObjectMapper().writeValueAsString to converto to String.

这篇关于“无法识别的令牌'com':正在期待('true','false'或'null')'"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆