callumlocke/json-formatter

Formatter fails on large file

EnnFour opened this issue · 7 comments

Looks like this fails when looking at the NBA schedule. It's ~120k lines, so maybe I've run into a size limitation? https://data.nba.com/data/10s/v2015/json/mobile_teams/nba/2016/league/00_full_schedule.json

Yes it currently has a hardcoded limit of 3,000,000 bytes (3 Mb). I added this years ago because I was worried about performance problems on huge JSON documents.

But I'm working on an update that will let you change this in the Options UI. (I might also increase the default limit, as computers are faster now.)

Until then, if you have an urgent need, you could edit it and install from source: just clone the repo, edit this line, and then follow the readme instructions to build & install from source.

btw it looks like that URL is just a little over the limit: 3360961 bytes (just checked with $('body>pre').textContent.length in devtools)

I'd love to see this configurable too. I just hit a limit of 3.4MB.

I've edited content.entry.ts to increase the rawLength condition. The built extension converts the json when > 3000000 bytes but for some reason it does not load the CSS. Tags/classes are present in source code but no style is displayed.

<style id="jfStyleEl">[object Object]

@media (prefers-color-scheme: dark) {
[object Object]
}</style>

Yes it currently has a hardcoded limit of 3,000,000 bytes (3 Mb). I added this years ago because I was worried about performance problems on huge JSON documents.
...
Until then, if you have an urgent need, you could edit it and install from source: just clone the repo, edit this line, and then follow the readme instructions to build & install from source.

@callumlocke Thanks for this extension. I noticed that line 63 that you linked to above, it sets a few properties including note: but I can't see anywhere in the repo where that value is ever used (or the other 2 properties tbh).
It doesn't even console.log {note}, which I was expecting to find at the very least... instead it seems like it will silently fail, so the user will not see any popup warning explanation or any change to the extension icon etc. 😟

const resultPromise = (async (): Promise<{
  formatted: boolean
  note: string
  rawLength: number | null
}> => {
...
return {
      formatted: false,
      note: `Too long`,
      rawLength,
}