bugGNU Octave - Bugs: bug #60688, jsondecode does not handle some...

 
 

bug #60688: jsondecode does not handle some arrays of structs correctly

Submitted by:  Mike Miller <mtmiller>
Submitted on:  Fri 28 May 2021 06:05:27 PM UTC  
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 28 May 2021 10:53:10 PM UTC, comment #3: 

Not a regression, these have probably always failed, they are just overlooked corner cases in the way that empty objects and singleton dimensions are handled.

I just rewound to https://hg.savannah.gnu.org/hgweb/octave/rev/38e22065d9ec and the same errors occur there.

Mike Miller <mtmiller>
Project Administrator
Fri 28 May 2021 10:15:14 PM UTC, comment #2: 

Were these always broken or is this a regression occurring after

changeset:   29708:fbcc3a680826
user:        Rik <rik@octave.org>
date:        Wed May 26 07:51:34 2021 -0700
summary:     Improve performance (> 100X) of jsondecode (bug #60625).

Rik <rik5>
Project Administrator
Fri 28 May 2021 06:12:20 PM UTC, comment #1: 

I've extracted the test cases, and fixed some whitespace issues, attached as json.tst to this bug report.

(file #51494)

Mike Miller <mtmiller>
Project Administrator
Fri 28 May 2021 06:05:27 PM UTC, original submission:  

Some of the test cases that I reported to the jsonstuff package were overlooked when these functions were added to Octave. The following JSON strings decode incorrectly or error in Octave:

jsondecode ('[{}]')
ans =

  0x0 struct array containing the fields:


jsondecode ('[[{}]]')
ans =
{
  [1,1] =

    0x0 struct array containing the fields:


}

jsondecode ('[[{"a": 1}]]')
error: octave_base_value::array_value(): wrong type argument 'scalar struct'

These should all decode to a scalar struct.

And these cases are all wrong, they should decode to struct arrays with dimensions 2×1, 1×2, and 1×1×2, respectively:

>> jsondecode ('[{}, {}]')
ans =

  0x0 struct array containing the fields:


>> jsondecode ('[[{}, {}]]')
ans =
{
  [1,1] =

    0x0 struct array containing the fields:


}

>> jsondecode ('[[[{}, {}]]]')
ans =
{
  [1,1] =
  {
    [1,1] =

      0x0 struct array containing the fields:


  }

}

You can find these test cases in https://github.com/apjanke/octave-jsonstuff.

Mike Miller <mtmiller>
Project Administrator

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #51494:  json.tst added by mtmiller (1KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-05-28 mtmiller StatusNeed Info => Confirmed
    2021-05-28 rik5 StatusNone => Need Info
    2021-05-28 mtmiller Attached File- => Added json.tst, #51494
    2021-05-28 mtmiller Carbon-CopyRemoved 80942 => -

    Back to the top


    Powered by Savane 3.6