简体   繁体   中英

com.fasterxml.jackson.core.JsonParseException for *.json.swp?

I have a JSON file that i want to deserialize by Jackson ObjectMapper

    private static ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);

    ...
    Foo foo1 = objectMapper.readValue(file, Foo.class);

the JSON file is valid(used a lint checker thing). the json file name looks like:

foo_(baz)_qux_-bar-quuz-corg-thud.json

the stack trace looks like:

   com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'b0VIM': was expecting ('true', 'false' or 'null')
     at [Source: .../.foo_(baz)_qux_-bar-quuz-corg-thud.json.swp; line: 1, column: 7]
   [testng]     at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702)
    ...

why is it saying it's having trouble with a token in the swap file? and the String b0VIM is not anywhere in the .json file. could the "(" be throwing it off?

what could I be missing?

thanks!

You're trying to de-serialize a VIM Swap file .
Usually those temporary files, which contains metadata on what you changed inside a file with the VIM editor, starts with b0VIM ( docs ).

Swap files have the .swp extension, and in fact the file name is

foo_(baz)_qux_-bar-quuz-corg-thud.json.swp

Swap files do not contain valid JSON.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM