octave-patch-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternati


From: Philip Nienhuis
Subject: [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json
Date: Tue, 21 Dec 2021 17:04:21 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0

Follow-up Comment #54, patch #9980 (project octave):

Yeah, parsing JSON is hard.

fromJSON-2.7.2 is much more stable, thanks, earlier version could crash on
several JSON files I tried.

I tried xulstore.json from my Firefox profile dir, see jsontrials.mat
(attached), where ans1 is from fromJSON and ans2 from jsondecode. To make it
easy I attached a "readjson.m" function kludge to read a json file into a text
string. One can see several differences. No idea if they're relevant.

Furthermore I tried another big JSOn file from the web, see
https://github.com/json-iterator/test-data/blob/master/large-file.json
On my laptop with Ryzen 7 5800U reading with fromJSON consumed 14 GB of 15 GB
available RAM (pfew, no trashing) and ran for more than an hour before I gave
up and went to bed. jsondecode did it within a few seconds. Yet to be fair,
parsing this large JSON files (25 MB) with a .m-script-based parser is just
far too ambitious. As for me I envision fromJSON and toJSON to be used on
"reasonable" files and data structures.

Yet when reading that big file fromJSON emitted endless warnings along this
line:

:
warning: colon arguments should be scalars
warning: called from
    fromJSON>_to_array_ at line 191 column 7
    fromJSON>_fromjson_ at line 127 column 22
    fromJSON>_to_struct_ at line 222 column 22
    fromJSON>_fromjson_ at line 128 column 22
    fromJSON>_to_struct_ at line 222 column 22
    fromJSON>_fromjson_ at line 128 column 22
    fromJSON>_to_array_ at line 200 column 29
    fromJSON>_fromjson_ at line 127 column 22
    fromJSON at line 117 column 10
    readjson at line 6 column 9


... which looks like a thing from Octave 7 & 8 where syntax checking became a
little stricter. I tried to debug this but couldn't pinpoint where it came
from. I saw no colons but they may be hidden in the eval command input. In the
latter case it isn't so much fromJSON's fault per se but maybe it should be
more robust.


(file #52545, file #52546, file #52547)
    _______________________________________________________

Additional Item Attachment:

File name: jsontrials.mat                 Size:1 KB
    <https://file.savannah.gnu.org/file/jsontrials.mat?file_id=52545>

File name: xulstore.json                  Size:0 KB
    <https://file.savannah.gnu.org/file/xulstore.json?file_id=52546>

File name: readjson.m                     Size:0 KB
    <https://file.savannah.gnu.org/file/readjson.m?file_id=52547>



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/patch/?9980>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]