[Top][All Lists]

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

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

From: anonymous
Subject: [Octave-patch-tracker] [patch #9980] JSON encoder and decoder, alternative to object2json
Date: Sat, 24 Oct 2020 11:54:58 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:81.0) Gecko/20100101 Firefox/81.0

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

I've uploaded a new version.  Aside from adding suggested testing
improvements, it they worker harder at mating native JSON/Javascript objects
with native Octave objects, namely ND arrays and struct arrays. 


Per comments, some more input checking and BIST has been added.  Pointing to
exact character position could be VERY helpful, but 'fromJSON' works
recursively, start with big blocks of string and working down to smaller
fragments.  As such, error position is a "nice to have".  Instead, 'fromJSON'
cites relevant fragments when malformed JSON is found.  


Per comments, more input checking and BIST have been added/fixed.  On exotics
like java or COM, the norm for stringifying non-(number,bool,string) is a
placeholder with a quoted-string of its class name (e.g. '"[SomeClass]"'),
which 'toJSON' observes. Provided that 'class()' works on any Octave object,
there are no "invalid" inputs, just unfullfilling outputs.  I've added a BIST
test with java object for verification.

On other input tests, i.e. PREC and COMPACT (formerly JSON), done. 

The input checking statement

isbool(PREC) && ([PREC,JSON] = {[],PREC}{}); 

is my preferred contraction for:

if isbool(PREC); 
    JSON = PREC;
    PREC = [];

The resulting bool value in irrelavent.  I understand comment about being

Regarding compatibility, 'toJSON' and 'fromJSON' is made to work with
Javscript's primative objects and its built-in parser ('JSON.parse' and
'JSON.stringify').  With all due respect, that is the standard to which any
JSON parser should rise.  If 'jsondecode' plays nicely with Javascript, then
'toJSON' should work with 'jsondecode'.

(file #50087, file #50088)

Additional Item Attachment:

File name: fromJSON_v2.m                  Size:17 KB

File name: toJSON_v2.m                    Size:13 KB


Reply to this item at:


  Message sent via Savannah

reply via email to

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