question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

parsing failing if file path is the json value

See original GitHub issue

jackson version: 2.6.4

file: test.json

[{
"name": "my application",
"folder": "/usr/lib/myApp"
}]

code:

ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(ALLOW_COMMENTS, TRUE); // tried other Features and combination, too.
JsonNode jsonNode = objectMapper.readTree("test.json");
System.out.println(jsonNode.asText());

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
sreevcommented, Mar 22, 2016

Come on, ‘readTree’ is overloaded, it also takes File and total 7 input types including String.

Please re-open.

private void _skipComment() throws IOException
{
    if (!isEnabled(Feature.ALLOW_COMMENTS)) {
        _reportUnexpectedChar('/', "maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)");
    }
    // First: check which comment (if either) it is:
    if (_inputPtr >= _inputEnd && !loadMore()) {
        _reportInvalidEOF(" in a comment");
    }
    char c = _inputBuffer[_inputPtr++];
    if (c == '/') {
        _skipLine();
    } else if (c == '*') {
        _skipCComment();
    } else { ///////////////////////////////////// this is where the issue is. after every backslash, it expects either / or * otherwise, it throws exception
        _reportUnexpectedChar(c, "was expecting either '*' or '/' for a comment");
    }
}
0reactions
cowtowncodercommented, Mar 30, 2016

@sreev ok. Glad you were able to find description of the intended argument type. Apologies for earlier rant.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parsing JSON from a file path is not working properly
The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string. You are feeding it a URL ......
Read more >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered....
Read more >
A problem with parsing JSON files located at a specific address
Here is the situation: I have a bundle of JSON-files in a specific directory (actually, the content of each file is in JSON-format,...
Read more >
Null in Parse JSON when Upload in Forms is Optional
Solved: I have a flow that is triggered when a user submits a response to a Microsoft Form. A user has the option...
Read more >
Loading JSON data from Cloud Storage | BigQuery
If you include a generation number in the Cloud Storage URI, then the load job fails. When you load JSON files into BigQuery,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found