discoveryjs/discovery

Some JSON is not parsed successfully

rualark opened this issue · 3 comments

Unfortunately, today I found JSON which is not parsed by JsonDiscovery at all. This JSON is parsed successfully by Visual Studio Code.

This big json is not much different from all the other big jsons that I used to parse with JsonDiscovery successfully.

Unfortunately, I cannot provide this json and it is too big to replace sensitive data (2 megabytes). But if you add some debugging logs to plugin, I will be able to see mistakes where parsing failed.

JsonDiscovery is using standard library to parse JSON, i.e. JSON.parse(). There are possible reasons JSON is not parsed:

  • Browser wraps JSON in a way that JsonDiscovery can't handle
  • JSON is not fully loaded
  • It actually malformed JSON and can't be parsed. If you serve JSON by a server, it may add something extra in response beside JSON itself

I'm not sure, is there is any error in console when parsing failing (I guess not, because it ). Just try to parse your JSON with Node.js (JSON.parse(require('./path/to.json'))), you will see an error if any. If no errors, then the reason in JSON detection.
VS Code uses it own parsers for incremental parsing and other stuff. It doesn't fail usually but shows warnings.

This issue should be in JsonDiscovery repo.
FYI @exdis

We are found the root cause of the problem (yeah, finally!). It's already fixed and waiting for publishing to stores.
See details in JsonDiscovery issue.