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

╄→гoц情女王★ 提交于 2020-03-13 11:27:29

问题


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"
        }
    }

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

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

How can I resolve that error?

This is how I converted this json into string:

staticFile1.setFile(file.toString());

And string to json:

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

回答1:


I believe you are getting an error like this

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]",

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.



来源:https://stackoverflow.com/questions/48962209/unrecognized-token-com-was-expecting-true-false-or-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!