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, 27 Oct 2020 18:34:35 -0400 (EDT)
User-agent: Mozilla/5.0 (Windows NT 6.1; rv:52.0) Gecko/20100101 Firefox/52.0

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

Thanks Ketan for the prompt updates.

With Octave-7.0.0:

>> test fromJSON
warning: Unclosed block: "[1,2,3"
warning: Unclosed block: "[[1,2,3],[3"
warning: Unclosed block: "[3"
warning: Unclosed block: "{a:3,b"
warning: Malformed struct frag: "{a:3,b ...}"
warning: Unclosed block: "{a:[[[1,3],[2,4]],[["
warning: Unclosed block: "{re:2,im:4"
warning: Invalid frag: "im mi{}ing quotes"
warning: Invalid frag: "garbage"
warning: Invalid frag: "garbage"
warning: Invalid frag: "garbage"
PASSES 68 out of 68 tests

>> test toJSON
PASSES 53 out of 53 tests


That noise can (and IMO should) be shut off; I did that by adding
%! warning ("off", "all", "local");
statements before the fromJSON calls provoking these warnings.

I've reworked the functional BIST tests for Octave-7.0.0's jsonencode and
jsondecode and after some editing attached them here as toJSON_BIST.tst and
fromJSON_BIST.tst.
I randomly chose the third "%% try higher dimensions for the array" test block
in fromJSON_BIST.tst,


%! json = ['[[[[1,-1], [2,-2]],[[3,-3],[4,-4]]],[[[5,-5],[6,-6]],[[7,-7],',
...
%!         '[8,-8]]],[[[9,-9], [10,-10]],[[11,-11],[12,-12]]],', ...
%!         '[[[13,-13],[14,-14]],[[15,-15],[16,-16]]]]'];
%! var1 = cat (3, [1, 3; 5, 7; 9, 11; 13, 15], [2, 4; 6, 8; 10, 12; 14, 16]);
%! var2 = cat (3, [-1, -3; -5, -7; -9, -11; -13, -15], ...
%!             [-2, -4; -6, -8; -10, -12; -14, -16]);
%! exp  = cat (4, var1, var2);
%! obs  = fromjSON (json);
%! assert (isequal (obs, exp));


and saw some different dimensions wih your fromJSON.
Similarly for some toJSON_BIST.tst tests.
In other (earlier) tests I saw that where jsondecode returns [] for 'null',
fromJSON returns NaN.
I hope you are willing to have a look at the tests in these files  and try
them with the toJSON and fromJSON functions.

As I know nothing about JSON (well, I know it exists); can you inform me if
the different test results are something to worry about?
*Background*:
I do not expect full Matlab compatibility. It's just that as package
maintainer I'd like functions to produce correct output, that is, output
sufficiently correct to be used out in the wild w/o provoking undue bug
reports. After all, we hope these new functions will attract new users rather
than put them off :-)
So do you think fromJSON.m and toJSON.m as they stand are "safe" enough to
include in the io package, or is more work needed?

They can always be included with the word "EXPERIMENTAL" (in capitals) in the
NEWS file.
That word is FWIW anyway :-)

On another note: once finally accepted,
* Before pushing to the repo I'll do some style edits (notably single quotes
=> double quotes). I don't mind, but you may also do it;
* I'll have a look at the Texinfo, no worries. I'm no Texinfo guru but I think
I can improve it a bit here and there.

Lastly:
Apologies if you expected your contributions to go rapidly and w/o much edits
into some Octave add-on package :-)  But correctness of functions is a Big
Thing for me and the io package is a "community package", a category for which
we think this counts a bit more than for external packages.
These functions will only get better this way.


    _______________________________________________________

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]